All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus
Date: Fri, 21 Oct 2011 14:32:59 -0500	[thread overview]
Message-ID: <4EA1C8EB.6090204@gmail.com> (raw)
In-Reply-To: <1319215897-6310-6-git-send-email-mikel.astiz@bmw-carit.de>

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

Hi Mikel,

On 10/21/2011 11:51 AM, Mikel Astiz wrote:
> ---
>  src/handsfree.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 58 insertions(+), 0 deletions(-)
> 
> diff --git a/src/handsfree.c b/src/handsfree.c
> index 24f2349..27af31c 100644
> --- a/src/handsfree.c
> +++ b/src/handsfree.c
> @@ -41,9 +41,12 @@
>  #include "ofono.h"
>  #include "common.h"
>  
> +#define MAX_AG_FEATURE_COUNT 32
> +

So you probably meant 33 here right?

>  static GSList *g_drivers = NULL;
>  
>  struct ofono_handsfree {
> +	unsigned int ag_features;
>  	ofono_bool_t inband_ringing;
>  	ofono_bool_t voice_recognition;
>  	ofono_bool_t voice_recognition_pending;
> @@ -54,6 +57,54 @@ struct ofono_handsfree {
>  	DBusMessage *pending;
>  };
>  
> +static void append_ag_features(struct ofono_handsfree *hf, char **features)
> +{
> +	unsigned int bit;
> +	int feature_count = 0;
> +
> +	for (bit = 1; bit != 0; bit <<= 1) {
> +		if (hf->ag_features & bit) {
> +			char *name = NULL;
> +
> +			switch ((enum hfp_ag_feature) bit) {
> +			case HFP_AG_FEATURE_VOICE_RECOG:
> +				name = "voice-recognition";
> +				break;
> +			case HFP_AG_FEATURE_ATTACH_VOICE_TAG:
> +				name = "attach-voice-tag";
> +				break;
> +			default:
> +				continue;
> +			}
> +
> +			features[feature_count++] = name;
> +		}
> +	}
> +
> +	features[feature_count] = NULL;
> +}
> +

This function seemed way too complicated for what you were trying to
accomplish.

> +void ofono_handsfree_set_ag_features(struct ofono_handsfree *hf,
> +					unsigned int ag_features)
> +{
> +	DBusConnection *conn = ofono_dbus_get_connection();
> +	const char *path = __ofono_atom_get_path(hf->atom);
> +	char **features;
> +
> +	if (hf->ag_features == ag_features)
> +		return;
> +
> +	hf->ag_features = ag_features;
> +
> +	features = g_new0(char *, MAX_AG_FEATURE_COUNT + 1);
> +	append_ag_features(hf, features);
> +	ofono_dbus_signal_array_property_changed(conn, path,
> +						OFONO_HANDSFREE_INTERFACE,
> +						"Features", DBUS_TYPE_STRING,
> +						&features);
> +	g_free(features);

I also didn't like this part.  The AG features should be set by the atom
driver prior to calling ofono_handsfree_register.  And since the BRSF
cannot be changed during the lifetime of the atom, there's no need for
signaling the property and the rest of the logic in this implementation.

> +}
> +
>  void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
>  						ofono_bool_t enabled)
>  {
> @@ -102,6 +153,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
>  	DBusMessageIter dict;
>  	dbus_bool_t inband_ringing;
>  	dbus_bool_t voice_recognition;
> +	char **features;
>  
>  	reply = dbus_message_new_method_return(msg);
>  	if (reply == NULL)
> @@ -121,6 +173,12 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
>  	ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
>  				&voice_recognition);
>  
> +	features = g_new0(char *, MAX_AG_FEATURE_COUNT + 1);
> +	append_ag_features(hf, features);
> +	ofono_dbus_dict_append_array(&dict, "Features", DBUS_TYPE_STRING,
> +					&features);
> +	g_free(features);
> +
>  	dbus_message_iter_close_container(&iter, &dict);
>  
>  	return reply;

I went ahead and pushed my own version of this patch.  Please review it
and let me know if you find any problems.

Regards,
-Denis

  reply	other threads:[~2011-10-21 19:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 01/12] include: Voice recognition in handsfree public api Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 02/12] handsfree: Implement voice recognition function Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 03/12] hfpmodem: Support for AT+BVRA Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 04/12] doc: Handsfree exposes supported AG features Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus Mikel Astiz
2011-10-21 19:32   ` Denis Kenzior [this message]
2011-10-21 16:51 ` [PATCH v4 06/12] hfpmodem: Report features supported by AG Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 07/12] hfpmodem: Avoid segfault in network-registration Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 08/12] hfpmodem: Avoid segfault in call-volume Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 09/12] hfpmodem: Avoid segfault in handsfree Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 10/12] devinfo: avoid crash if query_model not supported Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 11/12] hfpmodem: devinfo atom added to export BT address Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 12/12] hfp_hf: BT address exposed through Serial property Mikel Astiz
2011-10-21 19:33   ` Denis Kenzior
2011-10-21 19:30 ` [PATCH v4 00/12] Bluetooth HFP-specific extensions 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=4EA1C8EB.6090204@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.