All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] sim: add method to query SIM Retry Counter
@ 2010-12-20 21:56 Lucas De Marchi
  2010-12-20 21:56 ` [PATCH 2/4] sim: add PinRetries property Lucas De Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lucas De Marchi @ 2010-12-20 21:56 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/include/sim.h b/include/sim.h
index 7860e24..50529bb 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -108,6 +108,9 @@ typedef void (*ofono_sim_passwd_cb_t)(const struct ofono_error *error,
 					enum ofono_sim_password_type type,
 					void *data);
 
+typedef void (*ofono_sim_retry_counter_cb_t)(const struct ofono_error *error,
+					int retry_counter, void *data);
+
 typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
 					void *data);
 
@@ -144,6 +147,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_retry_counter)(struct ofono_sim *sim,
+			ofono_sim_retry_counter_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] 7+ messages in thread

* [PATCH 2/4] sim: add PinRetries property
  2010-12-20 21:56 [PATCH 1/4] sim: add method to query SIM Retry Counter Lucas De Marchi
@ 2010-12-20 21:56 ` Lucas De Marchi
  2010-12-20 21:56 ` [PATCH 3/4] doc: detail " Lucas De Marchi
  2010-12-20 21:56 ` [PATCH 4/4] atmodem: implement method to query PIN Retry Counter Lucas De Marchi
  2 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2010-12-20 21:56 UTC (permalink / raw)
  To: ofono

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

---
 src/sim.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 6217a25..8c05900 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 */
 
+	unsigned char pin_retries;
+
 	enum ofono_sim_phase phase;
 	unsigned char mnc_length;
 	enum ofono_sim_cphs_phase cphs_phase;
@@ -369,6 +371,9 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 				DBUS_TYPE_STRING,
 				(void *) &pin_name);
 
+	ofono_dbus_dict_append(&dict, "PinRetries",
+				DBUS_TYPE_BYTE, &sim->pin_retries);
+
 done:
 	dbus_message_iter_close_container(&iter, &dict);
 
@@ -1560,6 +1565,28 @@ static void sim_initialize_after_pin(struct ofono_sim *sim)
 			sim_cphs_information_read_cb, sim);
 }
 
+static void sim_retry_counter_query_cb(const struct ofono_error *error,
+					int retry, void *data)
+{
+	struct ofono_sim *sim = data;
+	DBusConnection *conn = ofono_dbus_get_connection();
+	const char *path = __ofono_atom_get_path(sim->atom);
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		ofono_error("Querying PIN Retry Counter failed");
+
+		return;
+	}
+
+	if (sim->pin_retries != retry) {
+		sim->pin_retries = retry;
+		ofono_dbus_signal_property_changed(conn, path,
+						OFONO_SIM_MANAGER_INTERFACE,
+						"PinRetries", DBUS_TYPE_BYTE,
+						&retry);
+	}
+}
+
 static void sim_pin_query_cb(const struct ofono_error *error,
 				enum ofono_sim_password_type pin_type,
 				void *data)
@@ -1592,6 +1619,11 @@ static void sim_pin_query_cb(const struct ofono_error *error,
 						&pin_name);
 	}
 
+	if (sim->driver->query_retry_counter != NULL) {
+		sim->driver->query_retry_counter(sim,
+					sim_retry_counter_query_cb, sim);
+	}
+
 checkdone:
 	if (pin_type == OFONO_SIM_PASSWORD_NONE)
 		sim_initialize_after_pin(sim);
-- 
1.7.3.4


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

* [PATCH 3/4] doc: detail PinRetries property
  2010-12-20 21:56 [PATCH 1/4] sim: add method to query SIM Retry Counter Lucas De Marchi
  2010-12-20 21:56 ` [PATCH 2/4] sim: add PinRetries property Lucas De Marchi
@ 2010-12-20 21:56 ` Lucas De Marchi
  2010-12-21  7:48   ` Sankar
  2010-12-20 21:56 ` [PATCH 4/4] atmodem: implement method to query PIN Retry Counter Lucas De Marchi
  2 siblings, 1 reply; 7+ messages in thread
From: Lucas De Marchi @ 2010-12-20 21:56 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/doc/sim-api.txt b/doc/sim-api.txt
index d4d2b1b..c7d1faa 100644
--- a/doc/sim-api.txt
+++ b/doc/sim-api.txt
@@ -145,3 +145,13 @@ Properties	boolean Present [readonly]
 
 			If BDN is enabled, oFono halts the SIM initialization
 			procedure and only emergency calls are allowed.
+
+		byte PinRetries [readonly]
+
+			Contains the retry counter for the current required
+			pin. This counter is tipically decremented whenever a
+			call to EnterPin() fails.
+
+			E.g.: if PinRequired is equal "puk", this property
+			contains the number of times EnterPin can be called
+			with a wrong puk.
-- 
1.7.3.4


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

* [PATCH 4/4] atmodem: implement method to query PIN Retry Counter
  2010-12-20 21:56 [PATCH 1/4] sim: add method to query SIM Retry Counter Lucas De Marchi
  2010-12-20 21:56 ` [PATCH 2/4] sim: add PinRetries property Lucas De Marchi
  2010-12-20 21:56 ` [PATCH 3/4] doc: detail " Lucas De Marchi
@ 2010-12-20 21:56 ` Lucas De Marchi
  2 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2010-12-20 21:56 UTC (permalink / raw)
  To: ofono

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

PIN retry counter is implemented for huaweimodem and it'd be very
similar for other vendors.
---
 drivers/atmodem/sim.c |   70 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 1653ede..4d0d40c 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -52,6 +52,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 +457,74 @@ 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_retry_counter_cb_t cb = cbd->cb;
+	const char *final = g_at_result_final_response(result);
+	GAtResultIter iter;
+	int retry;
+	struct ofono_error error;
+
+	decode_at_error(&error, final);
+
+	if (!ok) {
+		cb(&error, -1, 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;
+
+	/*
+	 * Number is optional. In case number is not present, pin is not
+	 * required.
+	 */
+	if (!g_at_result_iter_next_number(&iter, &retry))
+		retry = 0;
+
+	cb(&error, retry, cbd->data);
+
+	return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void at_pin_retry_query(struct ofono_sim *sim,
+				ofono_sim_retry_counter_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, -1, 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, -1, data);
+	}
+
+	CALLBACK_WITH_SUCCESS(cb, 0, data);
+}
+
 static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
@@ -886,6 +955,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_retry_counter	= at_pin_retry_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] 7+ messages in thread

* Re: [PATCH 3/4] doc: detail PinRetries property
  2010-12-20 21:56 ` [PATCH 3/4] doc: detail " Lucas De Marchi
@ 2010-12-21  7:48   ` Sankar
  2010-12-22 18:54     ` Lucas De Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Sankar @ 2010-12-21  7:48 UTC (permalink / raw)
  To: ofono

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

Hi Lucas,

On Tue, Dec 21, 2010 at 3:26 AM, Lucas De Marchi <
lucas.demarchi@profusion.mobi> wrote:

> ---
>  doc/sim-api.txt |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/doc/sim-api.txt b/doc/sim-api.txt
> index d4d2b1b..c7d1faa 100644
> --- a/doc/sim-api.txt
> +++ b/doc/sim-api.txt
> @@ -145,3 +145,13 @@ Properties boolean Present [readonly]
>
>                        If BDN is enabled, oFono halts the SIM
> initialization
>                        procedure and only emergency calls are allowed.
> +
> +               byte PinRetries [readonly]
> +
> +                       Contains the retry counter for the current required
> +                       pin. This counter is tipically decremented whenever
> a
> +                       call to EnterPin() fails.
> +
> +                       E.g.: if PinRequired is equal "puk", this property
> +                       contains the number of times EnterPin can be called
> +                       with a wrong puk.
>
Does this property also mention how many retries are possible when the user
enters a wrong PUK for unblocking the sim pin.

Thanks,
Sankar.

> --
> 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: 1934 bytes --]

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

* Re: [PATCH 3/4] doc: detail PinRetries property
  2010-12-21  7:48   ` Sankar
@ 2010-12-22 18:54     ` Lucas De Marchi
  2010-12-23  0:40       ` Denis Kenzior
  0 siblings, 1 reply; 7+ messages in thread
From: Lucas De Marchi @ 2010-12-22 18:54 UTC (permalink / raw)
  To: ofono

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

Hi,

On Tue, Dec 21, 2010 at 5:48 AM, Sankar <gsankar.gs@gmail.com> wrote:
>> +               byte PinRetries [readonly]
>> +
>> +                       Contains the retry counter for the current
>> required
>> +                       pin. This counter is tipically decremented
>> whenever a
>> +                       call to EnterPin() fails.
>> +
>> +                       E.g.: if PinRequired is equal "puk", this property
>> +                       contains the number of times EnterPin can be
>> called
>> +                       with a wrong puk.
>
> Does this property also mention how many retries are possible when the user
> enters a wrong PUK for unblocking the sim pin.

Interesting, but it was not what I had in mint. If we want this
behavior, we might have to return all the counters instead of only
one. Then, what would be the user interface?

regards,

Lucas De Marchi

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

* Re: [PATCH 3/4] doc: detail PinRetries property
  2010-12-22 18:54     ` Lucas De Marchi
@ 2010-12-23  0:40       ` Denis Kenzior
  0 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2010-12-23  0:40 UTC (permalink / raw)
  To: ofono

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

Hi Lucas,

On 12/22/2010 12:54 PM, Lucas De Marchi wrote:
> Hi,
> 
> On Tue, Dec 21, 2010 at 5:48 AM, Sankar <gsankar.gs@gmail.com> wrote:
>>> +               byte PinRetries [readonly]
>>> +
>>> +                       Contains the retry counter for the current
>>> required
>>> +                       pin. This counter is tipically decremented
>>> whenever a
>>> +                       call to EnterPin() fails.
>>> +
>>> +                       E.g.: if PinRequired is equal "puk", this property
>>> +                       contains the number of times EnterPin can be
>>> called
>>> +                       with a wrong puk.
>>
>> Does this property also mention how many retries are possible when the user
>> enters a wrong PUK for unblocking the sim pin.
> 
> Interesting, but it was not what I had in mint. If we want this
> behavior, we might have to return all the counters instead of only
> one. Then, what would be the user interface?
> 

This brings up an interesting point.  So here are the possible usecases:

The SIM is PIN locked and asks the user to enter a PIN.  The number of
tries remaining is shown to the user.  The pin is entered by using EnterPin.

The user has tried to use 'EnterPin' with the wrong code too many times
and the SIM PUK is now required.  The number of tries remaining should
be shown to the user.  The PUK and the new PIN is entered by using
ResetPin.  I believe the original question was about this case.

The user has entered the PIN correctly and the phone is initialized.  In
theory the PinRetries can be applicable here as well:

The user wants to unblock the PIN from being asked on the next sim
initialization.  He uses UnlockPin to do so.  The number of retries
remaining could be shown to the user.

The user wants to change his PIN from one to another.  He uses ChangePin
to do so.  The number of retries remaining could be shown to the user.

The user wants to make sure the PIN is asked on the next sim
initialization.  He uses LockPin to do so.  The number of retries
remaining should be could to the user.

The first two usecases are already nicely by your proposal, but the
others are not.  The question is, does anyone consider showing the
number of retries in the last three usecases important?

Regards,
-Denis

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

end of thread, other threads:[~2010-12-23  0:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-20 21:56 [PATCH 1/4] sim: add method to query SIM Retry Counter Lucas De Marchi
2010-12-20 21:56 ` [PATCH 2/4] sim: add PinRetries property Lucas De Marchi
2010-12-20 21:56 ` [PATCH 3/4] doc: detail " Lucas De Marchi
2010-12-21  7:48   ` Sankar
2010-12-22 18:54     ` Lucas De Marchi
2010-12-23  0:40       ` Denis Kenzior
2010-12-20 21:56 ` [PATCH 4/4] atmodem: implement method to query PIN Retry Counter 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.