Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/2] sim: add sim_ready_notify
@ 2010-08-24 14:24 Kristen Carlson Accardi
  2010-08-24 14:24 ` [PATCH 2/2] mbm: use sim_ready_notify Kristen Carlson Accardi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kristen Carlson Accardi @ 2010-08-24 14:24 UTC (permalink / raw)
  To: ofono

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

---
 include/sim.h |    2 ++
 src/sim.c     |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/include/sim.h b/include/sim.h
index 36a99b9..9b7d52e 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -187,6 +187,8 @@ enum ofono_sim_state ofono_sim_get_state(struct ofono_sim *sim);
 
 void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted);
 
+void ofono_sim_ready_notify(struct ofono_sim *sim);
+
 /* This will queue an operation to read all available records with id from the
  * SIM.  Callback cb will be called every time a record has been read, or once
  * if an error has occurred.  For transparent files, the callback will only
diff --git a/src/sim.c b/src/sim.c
index a450b30..55499fc 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -56,6 +56,9 @@ static void sim_own_numbers_update(struct ofono_sim *sim);
 static void sim_pin_check(struct ofono_sim *sim);
 static void sim_set_ready(struct ofono_sim *sim);
 
+#define SIM_STATUS_READY		1
+#define SIM_STATUS_WAITING_FOR_PIN	(1 << 1)
+
 struct sim_file_op {
 	int id;
 	gboolean cache;
@@ -78,6 +81,7 @@ struct ofono_sim {
 	GSList *new_numbers;
 	GSList *service_numbers;
 	gboolean sdn_ready;
+	unsigned int status;
 	enum ofono_sim_state state;
 	enum ofono_sim_password_type pin_type;
 	gboolean locked_pins[OFONO_SIM_PASSWORD_SIM_PUK]; /* Number of PINs */
@@ -1191,6 +1195,14 @@ checkdone:
 
 static void sim_pin_check(struct ofono_sim *sim)
 {
+	if (!(sim->status & SIM_STATUS_READY)) {
+		sim->status |= SIM_STATUS_WAITING_FOR_PIN;
+		return;
+	}
+
+	if (sim->status & SIM_STATUS_WAITING_FOR_PIN)
+		sim->status &= ~(SIM_STATUS_WAITING_FOR_PIN);
+
 	if (!sim->driver->query_passwd_state) {
 		sim_initialize_after_pin(sim);
 		return;
@@ -2004,6 +2016,16 @@ static void sim_free_state(struct ofono_sim *sim)
 	}
 
 	sim->mnc_length = 0;
+
+	sim->status = 0;
+}
+
+void ofono_sim_ready_notify(struct ofono_sim *sim)
+{
+	sim->status |= SIM_STATUS_READY;
+
+	if (sim->status & SIM_STATUS_WAITING_FOR_PIN)
+		sim_pin_check(sim);
 }
 
 void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
-- 
1.7.2.1


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

* [PATCH 2/2] mbm: use sim_ready_notify
  2010-08-24 14:24 [PATCH 1/2] sim: add sim_ready_notify Kristen Carlson Accardi
@ 2010-08-24 14:24 ` Kristen Carlson Accardi
  2010-08-24 21:32 ` [PATCH 1/2] sim: add sim_ready_notify Marcel Holtmann
  2010-08-25 13:32 ` Pekka Pessi
  2 siblings, 0 replies; 4+ messages in thread
From: Kristen Carlson Accardi @ 2010-08-24 14:24 UTC (permalink / raw)
  To: ofono

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

---
 plugins/mbm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/plugins/mbm.c b/plugins/mbm.c
index 8541aaf..5a82bf2 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -335,8 +335,11 @@ static void mbm_pre_sim(struct ofono_modem *modem)
 	sim = ofono_sim_create(modem, OFONO_VENDOR_MBM,
 					"atmodem", data->modem_port);
 
-	if (data->have_sim && sim)
+	if (sim)
 		ofono_sim_inserted_notify(sim, TRUE);
+
+	if (data->have_sim)
+		ofono_sim_ready_notify(sim);
 }
 
 static void mbm_post_sim(struct ofono_modem *modem)
-- 
1.7.2.1


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

* Re: [PATCH 1/2] sim: add sim_ready_notify
  2010-08-24 14:24 [PATCH 1/2] sim: add sim_ready_notify Kristen Carlson Accardi
  2010-08-24 14:24 ` [PATCH 2/2] mbm: use sim_ready_notify Kristen Carlson Accardi
@ 2010-08-24 21:32 ` Marcel Holtmann
  2010-08-25 13:32 ` Pekka Pessi
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2010-08-24 21:32 UTC (permalink / raw)
  To: ofono

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

Hi Kristen,
 
> +#define SIM_STATUS_READY		1
> +#define SIM_STATUS_WAITING_FOR_PIN	(1 << 1)
> +

as a general rule, I prefer if you also do (1 << 0) instead of 1. Sounds
maybe a bit silly a first, but it make it easier to read and more
consistent. And we let the compiler do the actual optimization ;)

Regards

Marcel



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

* Re: [PATCH 1/2] sim: add sim_ready_notify
  2010-08-24 14:24 [PATCH 1/2] sim: add sim_ready_notify Kristen Carlson Accardi
  2010-08-24 14:24 ` [PATCH 2/2] mbm: use sim_ready_notify Kristen Carlson Accardi
  2010-08-24 21:32 ` [PATCH 1/2] sim: add sim_ready_notify Marcel Holtmann
@ 2010-08-25 13:32 ` Pekka Pessi
  2 siblings, 0 replies; 4+ messages in thread
From: Pekka Pessi @ 2010-08-25 13:32 UTC (permalink / raw)
  To: ofono

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

Hi Kristen,

2010/8/24 Kristen Carlson Accardi <kristen@linux.intel.com>:
>  static void sim_pin_check(struct ofono_sim *sim)
>  {
> +       if (!(sim->status & SIM_STATUS_READY)) {
> +               sim->status |= SIM_STATUS_WAITING_FOR_PIN;
> +               return;
> +       }
> +
> +       if (sim->status & SIM_STATUS_WAITING_FOR_PIN)
> +               sim->status &= ~(SIM_STATUS_WAITING_FOR_PIN);
> +
>        if (!sim->driver->query_passwd_state) {
>                sim_initialize_after_pin(sim);
>                return;
> @@ -2004,6 +2016,16 @@ static void sim_free_state(struct ofono_sim *sim)
>        }
>
>        sim->mnc_length = 0;
> +
> +       sim->status = 0;
> +}
> +
> +void ofono_sim_ready_notify(struct ofono_sim *sim)
> +{
> +       sim->status |= SIM_STATUS_READY;
> +
> +       if (sim->status & SIM_STATUS_WAITING_FOR_PIN)
> +               sim_pin_check(sim);

I thought the idea was to call ofono_sim_ready_notify() some time
after entering the pin. Also, if there is no pin check or if it fails,
sim core should try to read pin-proteted files.

-- 
Pekka.Pessi mail at nokia.com

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

end of thread, other threads:[~2010-08-25 13:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-24 14:24 [PATCH 1/2] sim: add sim_ready_notify Kristen Carlson Accardi
2010-08-24 14:24 ` [PATCH 2/2] mbm: use sim_ready_notify Kristen Carlson Accardi
2010-08-24 21:32 ` [PATCH 1/2] sim: add sim_ready_notify Marcel Holtmann
2010-08-25 13:32 ` Pekka Pessi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox