All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Query retry counters
@ 2011-01-04 13:06 Lucas De Marchi
  2011-01-04 13:06 ` [PATCH v2 1/4] include: add method to query pin Retries Lucas De Marchi
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 13:06 UTC (permalink / raw)
  To: ofono

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

Here is the second implementation for the retry counter task. The difference
from the previous approach is that now a dict with all the available retry
counters is returned. This way is possible to query the retry counter even when
PinRequired == None, what allows us to properly handle calls to EnterPin(),
LockPin(), UnlockPin() and so on.

The dict has the form { pin = 3, puk = 10, ... }. The driver implementation for
huawei modem is done using its proprietary command, which returns 4 counters:

{SimManager} [/huawei0] Retries = { pin2 = 3, puk2 = 10, pin = 3, puk = 10 }

Lucas De Marchi (4):
  include: add method to query pin Retries
  sim: query remaining pin retries
  doc: detail Retries property
  atmodem: implement query for remaining pin retries

 doc/sim-api.txt       |   12 ++++++
 drivers/atmodem/sim.c |   99 +++++++++++++++++++++++++++++++++++++++++++++++
 include/sim.h         |   11 +++++
 src/sim.c             |  102 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 224 insertions(+), 0 deletions(-)

-- 
1.7.3.4


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/4] include: add method to query pin Retries
  2011-01-04 13:06 [PATCH v2 0/4] Query retry counters Lucas De Marchi
@ 2011-01-04 13:06 ` Lucas De Marchi
  2011-01-04 17:11   ` Denis Kenzior
  2011-01-04 13:06 ` [PATCH v2 2/4] sim: query remaining pin retries Lucas De Marchi
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 13:06 UTC (permalink / raw)
  To: ofono

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

---
 include/sim.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/sim.h b/include/sim.h
index 7860e24..bf4aaf9 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -77,6 +77,11 @@ enum ofono_sim_state {
 	OFONO_SIM_STATE_READY,
 };
 
+struct ofono_sim_pin_retry {
+	enum ofono_sim_password_type id;
+	int val;
+};
+
 typedef void (*ofono_sim_file_info_cb_t)(const struct ofono_error *error,
 					int filelength,
 					enum ofono_sim_file_structure structure,
@@ -108,6 +113,10 @@ typedef void (*ofono_sim_passwd_cb_t)(const struct ofono_error *error,
 					enum ofono_sim_password_type type,
 					void *data);
 
+typedef void (*ofono_sim_pin_retries_cb_t)(const struct ofono_error *error,
+						GSList *pin_retries,
+						void *data);
+
 typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
 					void *data);
 
@@ -144,6 +153,8 @@ struct ofono_sim_driver {
 			ofono_sim_passwd_cb_t cb, void *data);
 	void (*send_passwd)(struct ofono_sim *sim, const char *passwd,
 			ofono_sim_lock_unlock_cb_t cb, void *data);
+	void (*query_pin_retries)(struct ofono_sim *sim,
+				ofono_sim_pin_retries_cb_t cb, void *data);
 	void (*reset_passwd)(struct ofono_sim *sim, const char *puk,
 			const char *passwd,
 			ofono_sim_lock_unlock_cb_t cb, void *data);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/4] sim: query remaining pin retries
  2011-01-04 13:06 [PATCH v2 0/4] Query retry counters Lucas De Marchi
  2011-01-04 13:06 ` [PATCH v2 1/4] include: add method to query pin Retries Lucas De Marchi
@ 2011-01-04 13:06 ` Lucas De Marchi
  2011-01-04 17:13   ` Denis Kenzior
  2011-01-04 13:06 ` [PATCH v2 3/4] doc: detail Retries property Lucas De Marchi
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 13:06 UTC (permalink / raw)
  To: ofono

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

Check the remaining pin retries after each operation that might have
changed it, i.e. locking, unlocking, reseting or changing pin.
---
 src/sim.c |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 335f611..a57fe84 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -62,6 +62,8 @@ struct ofono_sim {
 	enum ofono_sim_password_type pin_type;
 	gboolean locked_pins[OFONO_SIM_PASSWORD_SIM_PUK]; /* Number of PINs */
 
+	GSList *pin_retries;
+
 	enum ofono_sim_phase phase;
 	unsigned char mnc_length;
 	enum ofono_sim_cphs_phase cphs_phase;
@@ -248,6 +250,27 @@ static char **get_locked_pins(struct ofono_sim *sim)
 	return ret;
 }
 
+static void **get_pin_retries(GSList *pin_retries)
+{
+	int nelem;
+	GSList *l;
+	void **ret;
+
+	nelem = g_slist_length(pin_retries) * 2;
+
+	ret = g_new0(void *, nelem + 1);
+
+	nelem = 0;
+	for (l = pin_retries; l; l = l->next) {
+		struct ofono_sim_pin_retry *retry = l->data;
+
+		ret[nelem++] = (void *)(sim_passwd_name(retry->id));
+		ret[nelem++] = &(retry->val);
+	}
+
+	return ret;
+}
+
 static char **get_service_numbers(GSList *service_numbers)
 {
 	int nelem;
@@ -287,6 +310,7 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 	char **service_numbers;
 	char **locked_pins;
 	const char *pin_name;
+	void **pin_retries;
 	dbus_bool_t present = sim->state != OFONO_SIM_STATE_NOT_PRESENT;
 	dbus_bool_t fdn;
 	dbus_bool_t bdn;
@@ -369,12 +393,75 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 				DBUS_TYPE_STRING,
 				(void *) &pin_name);
 
+	if (sim->pin_retries) {
+		pin_retries = get_pin_retries(sim->pin_retries);
+
+		ofono_dbus_dict_append_dict(&dict, "Retries", DBUS_TYPE_BYTE,
+								&pin_retries);
+
+		g_free(pin_retries);
+	}
+
 done:
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
 }
 
+static void sim_pin_retries_query_cb(const struct ofono_error *error,
+						GSList *lretries, void *data)
+{
+	struct ofono_sim *sim = data;
+	DBusConnection *conn = ofono_dbus_get_connection();
+	const char *path = __ofono_atom_get_path(sim->atom);
+	GSList *lnew, *lold;
+	void **pin_retries;
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		ofono_error("Querying remaining pin retries failed");
+
+		return;
+	}
+
+	for (lnew = lretries, lold = sim->pin_retries;
+			lnew && lold; lnew = lnew->next, lold = lold->next) {
+		struct ofono_sim_pin_retry *rnew = lnew->data;
+		struct ofono_sim_pin_retry *rold = lold->data;
+
+		if (rnew->id != rold->id || rnew->val != rold->val)
+			break;
+	}
+
+	if (lnew == NULL && lold == NULL) {
+		g_slist_foreach(lretries, (GFunc) g_free, NULL);
+		g_slist_free(lretries);
+
+		return;
+	}
+
+	g_slist_foreach(sim->pin_retries, (GFunc) g_free, NULL);
+	g_slist_free(sim->pin_retries);
+
+	sim->pin_retries = lretries;
+
+	pin_retries = get_pin_retries(sim->pin_retries);
+
+	ofono_dbus_signal_dict_property_changed(conn, path,
+					OFONO_SIM_MANAGER_INTERFACE, "Retries",
+					DBUS_TYPE_BYTE,	&pin_retries);
+
+	g_free(pin_retries);
+}
+
+static void sim_pin_retries_check(struct ofono_sim *sim)
+{
+	if (sim->driver->query_pin_retries == NULL)
+		return;
+
+	sim->driver->query_pin_retries(sim, sim_pin_retries_query_cb, sim);
+}
+
+
 static void msisdn_set_done(struct msisdn_set_request *req)
 {
 	DBusMessage *reply;
@@ -549,6 +636,8 @@ static void sim_locked_cb(struct ofono_sim *sim, gboolean locked)
 						"LockedPins", DBUS_TYPE_STRING,
 						&locked_pins);
 	g_strfreev(locked_pins);
+
+	sim_pin_retries_check(sim);
 }
 
 static void sim_unlock_cb(const struct ofono_error *error, void *data)
@@ -557,7 +646,10 @@ static void sim_unlock_cb(const struct ofono_error *error, void *data)
 
 	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
 		DBusMessage *reply = __ofono_error_failed(sim->pending);
+
 		__ofono_dbus_pending_reply(&sim->pending, reply);
+		sim_pin_retries_check(sim);
+
 		return;
 	}
 
@@ -570,7 +662,10 @@ static void sim_lock_cb(const struct ofono_error *error, void *data)
 
 	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
 		DBusMessage *reply = __ofono_error_failed(sim->pending);
+
 		__ofono_dbus_pending_reply(&sim->pending, reply);
+		sim_pin_retries_check(sim);
+
 		return;
 	}
 
@@ -639,11 +734,16 @@ static void sim_change_pin_cb(const struct ofono_error *error, void *data)
 	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
 		__ofono_dbus_pending_reply(&sim->pending,
 				__ofono_error_failed(sim->pending));
+
+		sim_pin_retries_check(sim);
+
 		return;
 	}
 
 	__ofono_dbus_pending_reply(&sim->pending,
 				dbus_message_new_method_return(sim->pending));
+
+	sim_pin_retries_check(sim);
 }
 
 static DBusMessage *sim_change_pin(DBusConnection *conn, DBusMessage *msg,
@@ -1594,6 +1694,8 @@ static void sim_pin_query_cb(const struct ofono_error *error,
 						&pin_name);
 	}
 
+	sim_pin_retries_check(sim);
+
 checkdone:
 	if (pin_type == OFONO_SIM_PASSWORD_NONE)
 		sim_initialize_after_pin(sim);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/4] doc: detail Retries property
  2011-01-04 13:06 [PATCH v2 0/4] Query retry counters Lucas De Marchi
  2011-01-04 13:06 ` [PATCH v2 1/4] include: add method to query pin Retries Lucas De Marchi
  2011-01-04 13:06 ` [PATCH v2 2/4] sim: query remaining pin retries Lucas De Marchi
@ 2011-01-04 13:06 ` Lucas De Marchi
  2011-01-04 13:06 ` [PATCH v2 4/4] atmodem: implement query for remaining pin retries Lucas De Marchi
  2011-01-04 13:20 ` [PATCH v2 0/4] Query retry counters Sankar
  4 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 13:06 UTC (permalink / raw)
  To: ofono

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

---
 doc/sim-api.txt |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/doc/sim-api.txt b/doc/sim-api.txt
index 89c321e..65c920d 100644
--- a/doc/sim-api.txt
+++ b/doc/sim-api.txt
@@ -145,3 +145,15 @@ Properties	boolean Present [readonly]
 
 			If BDN is enabled, oFono halts the SIM initialization
 			procedure and only emergency calls are allowed.
+
+		dict{string,byte} Retries [readonly]
+
+			Contains all the retry counters available. The possible
+			values for the first field are the same as in
+			PinRequired property. The second field contains is the
+			counter for that pin type.
+
+			This property is updated after each operation that
+			might have changed the retry counters, i.e. calls to
+			ChangePin(), EnterPin(), ResetPin() LockPin(),
+			UnlockPin().
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/4] atmodem: implement query for remaining pin retries
  2011-01-04 13:06 [PATCH v2 0/4] Query retry counters Lucas De Marchi
                   ` (2 preceding siblings ...)
  2011-01-04 13:06 ` [PATCH v2 3/4] doc: detail Retries property Lucas De Marchi
@ 2011-01-04 13:06 ` Lucas De Marchi
  2011-01-04 13:20 ` [PATCH v2 0/4] Query retry counters Sankar
  4 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 13:06 UTC (permalink / raw)
  To: ofono

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

Implement query method for the remaining pin retries on huawei modem.
---
 drivers/atmodem/sim.c |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 1653ede..3a35b21 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -44,6 +44,8 @@
 #define EF_STATUS_INVALIDATED 0
 #define EF_STATUS_VALID 1
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
 struct sim_data {
 	GAtChat *chat;
 	unsigned int vendor;
@@ -52,6 +54,7 @@ struct sim_data {
 
 static const char *crsm_prefix[] = { "+CRSM:", NULL };
 static const char *cpin_prefix[] = { "+CPIN:", NULL };
+static const char *xcpin_prefix[] = { "^CPIN:", NULL };
 static const char *clck_prefix[] = { "+CLCK:", NULL };
 static const char *none_prefix[] = { NULL };
 
@@ -456,6 +459,101 @@ static struct {
 	{ OFONO_SIM_PASSWORD_PHCORP_PUK,	"PH-CORP PUK"	},
 };
 
+static void at_xcpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_sim_pin_retries_cb_t cb = cbd->cb;
+	const char *final = g_at_result_final_response(result);
+	GSList *rlist = NULL;
+	size_t i;
+	GAtResultIter iter;
+	struct ofono_error error;
+	static enum ofono_sim_password_type _password_types[] = {
+		OFONO_SIM_PASSWORD_SIM_PUK,
+		OFONO_SIM_PASSWORD_SIM_PIN,
+		OFONO_SIM_PASSWORD_SIM_PUK2,
+		OFONO_SIM_PASSWORD_SIM_PIN2,
+	};
+
+	decode_at_error(&error, final);
+
+	if (!ok) {
+		cb(&error, NULL, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "^CPIN:"))
+		goto error;
+
+	/* Skip status since we are not interested in this */
+	if (!g_at_result_iter_skip_next(&iter))
+		goto error;
+
+	/* Skip "overall counter" since we'll grab each one individually */
+	if (!g_at_result_iter_skip_next(&iter))
+		goto error;
+
+	for (i = 0; i < ARRAY_SIZE(_password_types); i++) {
+		struct ofono_sim_pin_retry *retry;
+		int val;
+
+		if (!g_at_result_iter_next_number(&iter, &val))
+			goto error_free;
+
+		retry = g_new(struct ofono_sim_pin_retry, 1);
+		if (retry == NULL)
+			goto error_free;
+
+		retry->id = _password_types[i];
+		retry->val = val;
+
+		rlist = g_slist_prepend(rlist, retry);
+
+		DBG("retry counter id=%d, val=%d", retry->id, retry->val);
+	}
+
+	cb(&error, rlist, cbd->data);
+
+	return;
+
+error_free:
+	g_slist_foreach(rlist, (GFunc) g_free, NULL);
+	g_slist_free(rlist);
+
+error:
+	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+}
+
+static void at_pin_retries_query(struct ofono_sim *sim,
+				ofono_sim_pin_retries_cb_t cb, void *data)
+{
+	struct sim_data *sd = ofono_sim_get_data(sim);
+
+	DBG("");
+
+	if (sd->vendor == OFONO_VENDOR_QUALCOMM_MSM) {
+		struct cb_data *cbd = cb_data_new(cb, data);
+
+		if (cbd == NULL) {
+			CALLBACK_WITH_FAILURE(cb, NULL, data);
+
+			return;
+		}
+
+		if (g_at_chat_send(sd->chat, "AT^CPIN?", xcpin_prefix,
+					at_xcpin_cb, cbd, g_free) > 0)
+			return;
+
+		g_free(cbd);
+
+		CALLBACK_WITH_FAILURE(cb, NULL, data);
+	}
+
+	CALLBACK_WITH_SUCCESS(cb, NULL, data);
+}
+
 static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
@@ -886,6 +984,7 @@ static struct ofono_sim_driver driver = {
 	.write_file_cyclic	= at_sim_update_cyclic,
 	.read_imsi		= at_read_imsi,
 	.query_passwd_state	= at_pin_query,
+	.query_pin_retries	= at_pin_retries_query,
 	.send_passwd		= at_pin_send,
 	.reset_passwd		= at_pin_send_puk,
 	.lock			= at_pin_enable,
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/4] Query retry counters
  2011-01-04 13:06 [PATCH v2 0/4] Query retry counters Lucas De Marchi
                   ` (3 preceding siblings ...)
  2011-01-04 13:06 ` [PATCH v2 4/4] atmodem: implement query for remaining pin retries Lucas De Marchi
@ 2011-01-04 13:20 ` Sankar
  2011-01-04 14:24   ` Lucas De Marchi
  4 siblings, 1 reply; 11+ messages in thread
From: Sankar @ 2011-01-04 13:20 UTC (permalink / raw)
  To: ofono

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

Hi Lucas,

On Tue, Jan 4, 2011 at 6:36 PM, Lucas De Marchi <
lucas.demarchi@profusion.mobi> wrote:

> Here is the second implementation for the retry counter task. The
> difference
> from the previous approach is that now a dict with all the available retry
> counters is returned. This way is possible to query the retry counter even
> when
> PinRequired == None, what allows us to properly handle calls to EnterPin(),
> LockPin(), UnlockPin() and so on.
>
> The dict has the form { pin = 3, puk = 10, ... }. The driver implementation
> for
> huawei modem is done using its proprietary command, which returns 4
> counters:
>
> {SimManager} [/huawei0] Retries = { pin2 = 3, puk2 = 10, pin = 3, puk = 10
> }
>

How this information is retrieved at the oFono core. Is your solution to
maintain a counter or read the value from the sim elementary files?

Thanks,
Sankar.

>
> Lucas De Marchi (4):
>  include: add method to query pin Retries
>  sim: query remaining pin retries
>  doc: detail Retries property
>  atmodem: implement query for remaining pin retries
>
>  doc/sim-api.txt       |   12 ++++++
>  drivers/atmodem/sim.c |   99
> +++++++++++++++++++++++++++++++++++++++++++++++
>  include/sim.h         |   11 +++++
>  src/sim.c             |  102
> +++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 224 insertions(+), 0 deletions(-)
>
> --
> 1.7.3.4
>
> _______________________________________________
> ofono mailing list
> ofono(a)ofono.org
> http://lists.ofono.org/listinfo/ofono
>

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 2129 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/4] Query retry counters
  2011-01-04 13:20 ` [PATCH v2 0/4] Query retry counters Sankar
@ 2011-01-04 14:24   ` Lucas De Marchi
  0 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 14:24 UTC (permalink / raw)
  To: ofono

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

Hi Sankar

Em 04/01/2011 11:20, "Sankar" <gsankar.gs@gmail.com> escreveu:
> On Tue, Jan 4, 2011 at 6:36 PM, Lucas De Marchi <lucas.demarchi@profusion.mobi> wrote:
>>
>> Here is the second implementation for the retry counter task. The difference
>> from the previous approach is that now a dict with all the available retry
>> counters is returned. This way is possible to query the retry counter even when
>> PinRequired == None, what allows us to properly handle calls to EnterPin(),
>> LockPin(), UnlockPin() and so on.
>>
>> The dict has the form { pin = 3, puk = 10, ... }. The driver implementation for
>> huawei modem is done using its proprietary command, which returns 4 counters:
>>
>> {SimManager} [/huawei0] Retries = { pin2 = 3, puk2 = 10, pin = 3, puk = 10 }
>
>
> How this information is retrieved at the oFono core. Is your solution to maintain a counter or read the value from the sim elementary files?

Each vendor has proprietary commands to read these counters. For
example, on huawei you can get the retry counters by sending
"AT^CPIN?". Last version of 27.007 included an AT command for that
(+CPINR), so it's possible to have a generic implementation for
atmodem. However I don't know what vendors already support it.



regards,

Lucas De Marchi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/4] include: add method to query pin Retries
  2011-01-04 13:06 ` [PATCH v2 1/4] include: add method to query pin Retries Lucas De Marchi
@ 2011-01-04 17:11   ` Denis Kenzior
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-01-04 17:11 UTC (permalink / raw)
  To: ofono

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

Hi Lucas,

On 01/04/2011 07:06 AM, Lucas De Marchi wrote:
> ---
>  include/sim.h |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/include/sim.h b/include/sim.h
> index 7860e24..bf4aaf9 100644
> --- a/include/sim.h
> +++ b/include/sim.h
> @@ -77,6 +77,11 @@ enum ofono_sim_state {
>  	OFONO_SIM_STATE_READY,
>  };
>  
> +struct ofono_sim_pin_retry {
> +	enum ofono_sim_password_type id;
> +	int val;
> +};
> +
>  typedef void (*ofono_sim_file_info_cb_t)(const struct ofono_error *error,
>  					int filelength,
>  					enum ofono_sim_file_structure structure,
> @@ -108,6 +113,10 @@ typedef void (*ofono_sim_passwd_cb_t)(const struct ofono_error *error,
>  					enum ofono_sim_password_type type,
>  					void *data);
>  
> +typedef void (*ofono_sim_pin_retries_cb_t)(const struct ofono_error *error,
> +						GSList *pin_retries,

One of the restrictions on the public ofono API is that we cannot use G*
types.  We can solve this in several ways:

- Use an array of ints with the size always being
OFONO_SIM_PASSWORD_INVALID.  The integer value contains the number of
retries or -1 if unknown / unsupported.

- Use an int length, struct ofono_sim_pin_retry *retries elements.  This
is similar to the approach taken in e.g. voicecall ofono_call_list_cb_t
or netreg ofono_netreg_operator_list_cb_t

> +						void *data);
> +
>  typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
>  					void *data);
>  
> @@ -144,6 +153,8 @@ struct ofono_sim_driver {
>  			ofono_sim_passwd_cb_t cb, void *data);
>  	void (*send_passwd)(struct ofono_sim *sim, const char *passwd,
>  			ofono_sim_lock_unlock_cb_t cb, void *data);
> +	void (*query_pin_retries)(struct ofono_sim *sim,
> +				ofono_sim_pin_retries_cb_t cb, void *data);
>  	void (*reset_passwd)(struct ofono_sim *sim, const char *puk,
>  			const char *passwd,
>  			ofono_sim_lock_unlock_cb_t cb, void *data);

Regards,
-Denis

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 2/4] sim: query remaining pin retries
  2011-01-04 13:06 ` [PATCH v2 2/4] sim: query remaining pin retries Lucas De Marchi
@ 2011-01-04 17:13   ` Denis Kenzior
  2011-01-04 17:26     ` Lucas De Marchi
  0 siblings, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2011-01-04 17:13 UTC (permalink / raw)
  To: ofono

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

Hi Lucas,

On 01/04/2011 07:06 AM, Lucas De Marchi wrote:
> Check the remaining pin retries after each operation that might have
> changed it, i.e. locking, unlocking, reseting or changing pin.
> ---
>  src/sim.c |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 102 insertions(+), 0 deletions(-)
> 
> diff --git a/src/sim.c b/src/sim.c
> index 335f611..a57fe84 100644
> --- a/src/sim.c
> +++ b/src/sim.c
> @@ -62,6 +62,8 @@ struct ofono_sim {
>  	enum ofono_sim_password_type pin_type;
>  	gboolean locked_pins[OFONO_SIM_PASSWORD_SIM_PUK]; /* Number of PINs */
>  
> +	GSList *pin_retries;
> +

Are you forgetting to free the pin_retries array when the sim is removed
or the sim atom is destroyed?

The rest seems fine to me.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 2/4] sim: query remaining pin retries
  2011-01-04 17:13   ` Denis Kenzior
@ 2011-01-04 17:26     ` Lucas De Marchi
  2011-01-04 17:29       ` Denis Kenzior
  0 siblings, 1 reply; 11+ messages in thread
From: Lucas De Marchi @ 2011-01-04 17:26 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

On Tue, Jan 4, 2011 at 3:13 PM, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Lucas,
>
> On 01/04/2011 07:06 AM, Lucas De Marchi wrote:
>> @@ -62,6 +62,8 @@ struct ofono_sim {
>>       enum ofono_sim_password_type pin_type;
>>       gboolean locked_pins[OFONO_SIM_PASSWORD_SIM_PUK]; /* Number of PINs */
>>
>> +     GSList *pin_retries;
>> +
>
> Are you forgetting to free the pin_retries array when the sim is removed
> or the sim atom is destroyed?
>

Yes, I forgot. Since I cannot have G* types on headers, I'll store a
ofono_sim_pin_retry **retries here and convert the code so the list
will not be necessary. Is this ok?


> The rest seems fine to me.
>

thanks
regards,


Lucas De Marchi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 2/4] sim: query remaining pin retries
  2011-01-04 17:26     ` Lucas De Marchi
@ 2011-01-04 17:29       ` Denis Kenzior
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-01-04 17:29 UTC (permalink / raw)
  To: ofono

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

Hi Lucas,

On 01/04/2011 11:26 AM, Lucas De Marchi wrote:
> Hi Denis,
> 
> On Tue, Jan 4, 2011 at 3:13 PM, Denis Kenzior <denkenz@gmail.com> wrote:
>> Hi Lucas,
>>
>> On 01/04/2011 07:06 AM, Lucas De Marchi wrote:
>>> @@ -62,6 +62,8 @@ struct ofono_sim {
>>>       enum ofono_sim_password_type pin_type;
>>>       gboolean locked_pins[OFONO_SIM_PASSWORD_SIM_PUK]; /* Number of PINs */
>>>
>>> +     GSList *pin_retries;
>>> +
>>
>> Are you forgetting to free the pin_retries array when the sim is removed
>> or the sim atom is destroyed?
>>
> 
> Yes, I forgot. Since I cannot have G* types on headers, I'll store a
> ofono_sim_pin_retry **retries here and convert the code so the list
> will not be necessary. Is this ok?

Should be fine.  See how it works out.  Just remember that the drivers
are free to return arrays on the stack, so you cannot assume ownership.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-01-04 17:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-04 13:06 [PATCH v2 0/4] Query retry counters Lucas De Marchi
2011-01-04 13:06 ` [PATCH v2 1/4] include: add method to query pin Retries Lucas De Marchi
2011-01-04 17:11   ` Denis Kenzior
2011-01-04 13:06 ` [PATCH v2 2/4] sim: query remaining pin retries Lucas De Marchi
2011-01-04 17:13   ` Denis Kenzior
2011-01-04 17:26     ` Lucas De Marchi
2011-01-04 17:29       ` Denis Kenzior
2011-01-04 13:06 ` [PATCH v2 3/4] doc: detail Retries property Lucas De Marchi
2011-01-04 13:06 ` [PATCH v2 4/4] atmodem: implement query for remaining pin retries Lucas De Marchi
2011-01-04 13:20 ` [PATCH v2 0/4] Query retry counters Sankar
2011-01-04 14:24   ` Lucas De Marchi

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.