Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 5/5] atmodem: sim-auth atom driver.
Date: Tue, 18 Jan 2011 13:30:28 -0600	[thread overview]
Message-ID: <4D35EA54.9030902@gmail.com> (raw)
In-Reply-To: <1295285934-9306-5-git-send-email-andrew.zaborowski@intel.com>

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

Hi Andrew,

> +static void at_discover_apps_cb(gboolean ok, GAtResult *result,
> +				gpointer user_data)
> +{
> +	struct cb_data *cbd = user_data;
> +	GAtResultIter iter;
> +	ofono_sim_list_apps_cb_t cb = cbd->cb;
> +	struct ofono_error error;
> +	GSList *list = NULL, *i;
> +	struct ofono_sim_app_record *buffer;
> +	int j, n;
> +
> +	decode_at_error(&error, g_at_result_final_response(result));
> +
> +	if (!ok) {
> +		cb(&error, NULL, 0, cbd->data);
> +		return;
> +	}
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	while (g_at_result_iter_next(&iter, "+CUAD:")) {
> +		const guint8 *obj_str;
> +		gint len;
> +
> +		if (!g_at_result_iter_next_hexstring(&iter, &obj_str, &len))
> +			goto error;
> +
> +		i = sim_parse_app_template_entries(obj_str, len);
> +		if (i == NULL)
> +			goto error;
> +
> +		list = g_slist_concat(i, list);
> +	}
> +

Since we potentially multiple results, what do you think of using an
approach similar to how phonebook works.  E.g. a simple:

typedef void (*ofono_sim_auth_cb_t)(const struct ofono_error *error,
                                        void *data);

and ofono_sim_auth_app_record(struct ofono_sim_auth *sa, unsigned char
*record, int len);

This would work nicely even for drivers using CRSM I think...

> +	n = g_slist_length(list);
> +	buffer = g_new(struct ofono_sim_app_record, n);
> +
> +	for (i = list, j = n - 1; i != NULL; i = i->next, i--)
> +		memcpy(&buffer[j], i->data, sizeof(*buffer));
> +
> +	cb(&error, buffer, n, cbd->data);
> +
> +	g_free(buffer);
> +	goto done;
> +
> +error:
> +	CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
> +
> +done:
> +	while (list) {
> +		i = list;
> +		list = list->next;
> +
> +		g_free(((struct ofono_sim_app_record *) i->data)->label);
> +		g_free(i->data);
> +		g_slist_free_1(i);
> +	}
> +}

Regards,
-Denis

  reply	other threads:[~2011-01-18 19:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 17:38 [PATCH 1/5] Add SIM authentication atom's driver definitions Andrzej Zaborowski
2011-01-17 17:38 ` [PATCH 2/5] simutil: SIM applications directory decoding utils Andrzej Zaborowski
2011-01-18 19:22   ` Denis Kenzior
2011-01-17 17:38 ` [PATCH 3/5] unit: Add a test for applications directory decoding utility Andrzej Zaborowski
2011-01-17 17:38 ` [PATCH 4/5] Add the sim-auth atom Andrzej Zaborowski
2011-01-17 17:38 ` [PATCH 5/5] atmodem: sim-auth atom driver Andrzej Zaborowski
2011-01-18 19:30   ` Denis Kenzior [this message]
2011-01-18 19:21 ` [PATCH 1/5] Add SIM authentication atom's driver definitions 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=4D35EA54.9030902@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