All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/2] sim: add ofono_sim_ready_notify() support
Date: Wed, 25 Aug 2010 04:23:11 -0700	[thread overview]
Message-ID: <1282735392-5283-2-git-send-email-kristen@linux.intel.com> (raw)
In-Reply-To: <1282735392-5283-1-git-send-email-kristen@linux.intel.com>

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

---
 include/sim.h |    2 ++
 src/sim.c     |   25 +++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 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 04a708b..b76a263 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_READY	(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 */
@@ -686,15 +690,20 @@ static void sim_enter_pin_cb(const struct ofono_error *error, void *data)
 {
 	struct ofono_sim *sim = data;
 	DBusMessage *reply;
+	gboolean ok = (error->type == OFONO_ERROR_TYPE_NO_ERROR);
 
-	if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+	if (!ok)
 		reply = __ofono_error_failed(sim->pending);
 	else
 		reply = dbus_message_new_method_return(sim->pending);
 
 	__ofono_dbus_pending_reply(&sim->pending, reply);
 
-	sim_pin_check(sim);
+	if (ok && (sim->status & SIM_STATUS_READY)) {
+		sim->status &= ~SIM_STATUS_WAITING_FOR_READY;
+		sim_pin_check(sim);
+	} else
+		sim->status |= SIM_STATUS_WAITING_FOR_READY;
 }
 
 static DBusMessage *sim_enter_pin(DBusConnection *conn, DBusMessage *msg,
@@ -2002,6 +2011,18 @@ 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_READY) {
+		sim->status &= ~SIM_STATUS_WAITING_FOR_READY;
+		sim_pin_check(sim);
+	}
 }
 
 void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
-- 
1.7.2.1


  reply	other threads:[~2010-08-25 11:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25 11:23 [PATCH 0/2] ofono_sim_ready_notify Kristen Carlson Accardi
2010-08-25 11:23 ` Kristen Carlson Accardi [this message]
2010-08-26 12:17   ` [PATCH 1/2] sim: add ofono_sim_ready_notify() support Pekka Pessi
2010-08-26 15:18     ` Denis Kenzior
2010-08-26 15:49     ` Pekka Pessi
2010-08-26 16:10       ` Denis Kenzior
2010-08-25 11:23 ` [PATCH 2/2] atmodem: call sim_ready_notify when epev is received Kristen Carlson Accardi

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=1282735392-5283-2-git-send-email-kristen@linux.intel.com \
    --to=kristen@linux.intel.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 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.