From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v3 04/15] handsfree: Implement voice recognition function
Date: Thu, 20 Oct 2011 20:32:13 -0500 [thread overview]
Message-ID: <4EA0CB9D.7030406@gmail.com> (raw)
In-Reply-To: <1319128700-15841-5-git-send-email-mikel.astiz@bmw-carit.de>
[-- Attachment #1: Type: text/plain, Size: 4417 bytes --]
Hi Mikel,
On 10/20/2011 11:38 AM, Mikel Astiz wrote:
> ---
> src/handsfree.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 72 insertions(+), 0 deletions(-)
>
> diff --git a/src/handsfree.c b/src/handsfree.c
> index efebcc0..7f3882f 100644
> --- a/src/handsfree.c
> +++ b/src/handsfree.c
> @@ -45,6 +45,9 @@ static GSList *g_drivers = NULL;
>
> struct ofono_handsfree {
> ofono_bool_t inband_ringing;
> + ofono_bool_t voicerec_state;
> + ofono_bool_t pending_voicerec_state;
Please name these voice_recognition and voice_recognition_pending.
> +
> const struct ofono_handsfree_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> @@ -72,6 +75,24 @@ void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
> &dbus_enabled);
> }
>
> +void ofono_handsfree_set_voice_recognition(struct ofono_handsfree *hf,
> + ofono_bool_t enabled)
> +{
> + DBusConnection *conn = ofono_dbus_get_connection();
> + const char *path = __ofono_atom_get_path(hf->atom);
> + dbus_bool_t dbus_enabled = enabled;
> +
> + if (hf->voicerec_state == enabled)
> + return;
> +
> + hf->voicerec_state = enabled;
> +
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_HANDSFREE_INTERFACE,
> + "VoiceRecognition", DBUS_TYPE_BOOLEAN,
> + &dbus_enabled);
> +}
> +
> static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> DBusMessage *msg, void *data)
> {
> @@ -80,6 +101,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> DBusMessageIter iter;
> DBusMessageIter dict;
> dbus_bool_t inband_ringing;
> + dbus_bool_t voicerec_state;
>
> reply = dbus_message_new_method_return(msg);
> if (reply == NULL)
> @@ -95,17 +117,49 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
> &inband_ringing);
>
> + voicerec_state = hf->voicerec_state;
> + ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
> + &voicerec_state);
> +
> dbus_message_iter_close_container(&iter, &dict);
>
> return reply;
> }
>
> +static void voicerec_set_cb(const struct ofono_error *error, void *data)
> +{
> + struct ofono_handsfree *hf = data;
> + DBusConnection *conn = ofono_dbus_get_connection();
> + const char *path = __ofono_atom_get_path(hf->atom);
> +
> + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
> + __ofono_dbus_pending_reply(&hf->pending,
> + __ofono_error_failed(hf->pending));
> + return;
> + }
> +
> + hf->voicerec_state = hf->pending_voicerec_state;
> +
> + __ofono_dbus_pending_reply(&hf->pending,
> + dbus_message_new_method_return(hf->pending));
> +
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_HANDSFREE_INTERFACE,
> + "VoiceRecognition",
> + DBUS_TYPE_BOOLEAN,
> + &hf->voicerec_state);
> +}
> +
> static DBusMessage *handsfree_set_property(DBusConnection *conn,
> DBusMessage *msg, void *data)
> {
> + struct ofono_handsfree *hf = data;
> DBusMessageIter iter, var;
> const char *name;
>
> + if (hf->pending)
> + return __ofono_error_busy(msg);
> +
> if (dbus_message_iter_init(msg, &iter) == FALSE)
> return __ofono_error_invalid_args(msg);
>
> @@ -120,6 +174,24 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
>
> dbus_message_iter_recurse(&iter, &var);
>
> + if (g_str_equal(name, "VoiceRecognition") == TRUE) {
> + ofono_bool_t enabled;
> +
> + if (!hf->driver->voice_recognition)
> + return __ofono_error_not_implemented(msg);
> +
> + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
> + return __ofono_error_invalid_args(msg);
> +
> + dbus_message_iter_get_basic(&var, &enabled);
> +
> + hf->pending_voicerec_state = enabled;
> + hf->pending = dbus_message_ref(msg);
> + hf->driver->voice_recognition(hf, enabled, voicerec_set_cb, hf);
> +
You might want to think about whether we need to be a bit smarter here.
For example, AG indicated BVRA is active, and us trying to set (and
potentially signal PropertyChanged) again might be bad.
Same goes for setting the property to the already set value.
> + return NULL;
> + }
> +
> return __ofono_error_invalid_args(msg);
> }
>
Regards,
-Denis
next prev parent reply other threads:[~2011-10-21 1:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-20 16:38 [PATCH v3 00/15] Bluetooth HFP-specific extensions Mikel Astiz
2011-10-20 16:38 ` [PATCH v3 01/15] hfpmodem: Support for +BSIR unsol. result codes Mikel Astiz
2011-10-20 17:58 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 02/15] doc: Voice recognition function added in Handsfree Mikel Astiz
2011-10-21 1:33 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 03/15] include: Voice recognition in handsfree public api Mikel Astiz
2011-10-21 1:27 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 04/15] handsfree: Implement voice recognition function Mikel Astiz
2011-10-21 1:32 ` Denis Kenzior [this message]
2011-10-20 16:38 ` [PATCH v3 05/15] hfpmodem: Support for AT+BVRA Mikel Astiz
2011-10-20 16:38 ` [PATCH v3 06/15] doc: Handsfree exposes supported AG features Mikel Astiz
2011-10-21 1:36 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 07/15] include: AG features added to handsfree public api Mikel Astiz
2011-10-21 1:38 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 08/15] handsfree: Supported AG features exposed in D-Bus Mikel Astiz
2011-10-20 16:38 ` [PATCH v3 09/15] hfpmodem: Report features supported by AG Mikel Astiz
2011-10-20 16:38 ` [PATCH v3 10/15] hfpmodem: Avoid segfault in network-registration Mikel Astiz
2011-10-20 17:59 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 11/15] hfpmodem: Avoid segfault in call-volume Mikel Astiz
2011-10-20 16:38 ` [PATCH v3 12/15] hfpmodem: Avoid segfault in handsfree Mikel Astiz
2011-10-20 16:38 ` [PATCH v3 13/15] hfpmodem: devinfo atom added to export BT address Mikel Astiz
2011-10-21 1:40 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 14/15] hfp_hf: BT address exposed through Serial property Mikel Astiz
2011-10-21 1:42 ` Denis Kenzior
2011-10-20 16:38 ` [PATCH v3 15/15] hfpmodem: minor whitespace fix Mikel Astiz
2011-10-20 17:58 ` Denis Kenzior
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=4EA0CB9D.7030406@gmail.com \
--to=denkenz@gmail.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.