Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] emulator: add AT hook_control_cb() CB and register it
Date: Tue, 29 Mar 2011 22:49:39 -0500	[thread overview]
Message-ID: <4D92A853.7000002@gmail.com> (raw)
In-Reply-To: <1300962329-24257-1-git-send-email-guillaume.zajac@linux.intel.com>

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

Hi Guillaume,

On 03/24/2011 05:25 AM, Guillaume Zajac wrote:
> ---
>  src/emulator.c |   44 +++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 41 insertions(+), 3 deletions(-)
> 
> diff --git a/src/emulator.c b/src/emulator.c
> index c84f0a9..586c7ec 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -177,6 +177,41 @@ error:
>  	g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
>  }
>  
> +static void hook_control_cb(GAtServer *server, GAtServerRequestType type,

Can you rename this dun_ath_cb, since this is pretty much dun specific

> +			GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_emulator *em = user_data;
> +	GAtResultIter iter;
> +	int val;
> +
> +	DBG("");
> +
> +	if (type != G_AT_SERVER_REQUEST_TYPE_SET)
> +		goto error;

Wouldn't we be also getting G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY here?

> +
> +	if (em->ppp == NULL)
> +		goto error;
> +
> +	g_at_result_iter_init(&iter, result);
> +	g_at_result_iter_next(&iter, "");
> +
> +	if (g_at_result_iter_next_number(&iter, &val) == FALSE)
> +		goto error;
> +
> +	if (val != 0)
> +		goto error;
> +
> +	g_at_ppp_unref(em->ppp);
> +	em->ppp = NULL;
> +
> +	g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +
> +	return;
> +
> +error:
> +	g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> +}
> +
>  static void brsf_cb(GAtServer *server, GAtServerRequestType type,
>  			GAtResult *result, gpointer user_data)
>  {
> @@ -466,10 +501,13 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
>  
>  	__ofono_atom_register(em->atom, emulator_unregister);
>  
> -	if (em->type == OFONO_EMULATOR_TYPE_DUN)
> +	if (em->type == OFONO_EMULATOR_TYPE_DUN) {
>  		g_at_server_register(em->server, "D", dial_cb, em, NULL);
> -	else if (em->type == OFONO_EMULATOR_TYPE_HFP)
> -		g_at_server_set_echo(em->server, FALSE);
> +		g_at_server_register(em->server, "H", hook_control_cb, em, NULL);
> +	} else {
> +		if (em->type == OFONO_EMULATOR_TYPE_HFP)
> +			g_at_server_set_echo(em->server, FALSE);

I'd really prefer this to use a switch/case statement.

> +	}
>  }
>  
>  static void emulator_remove(struct ofono_atom *atom)

Regards,
-Denis

  reply	other threads:[~2011-03-30  3:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24 10:25 [PATCH] emulator: add AT hook_control_cb() CB and register it Guillaume Zajac
2011-03-30  3:49 ` Denis Kenzior [this message]
2011-03-30  8:02   ` Guillaume Zajac
2011-03-30 14:39     ` 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=4D92A853.7000002@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox