All of lore.kernel.org
 help / color / mirror / Atom feed
From: andrzej zaborowski <balrogg@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] [RFC] Do the PIN check in SIMManager
Date: Wed, 23 Sep 2009 22:47:54 +0200	[thread overview]
Message-ID: <fb249edb0909231347ha981387ge221b34f1e2e4839@mail.gmail.com> (raw)
In-Reply-To: <200909220012.29847.denkenz@gmail.com>

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

Hi,

2009/9/22 Denis Kenzior <denkenz@gmail.com>:
>> authentication, you have to give the old password from before it was
>> changed to "", i.e to disable and enable SIM PIN, do:
>> SimManager.ChangePin("pin", "1234", "")
>> SimManager.ChangePin("pin", "1234", "1234")
>>
>> rather than the more logical
>>
>> SimManager.ChangePin("pin", "1234", "")
>> SimManager.ChangePin("pin, "", "1234)
>>
>> The other problem is that if changing the password succeeds but
>> enabling authentiation fails, ChangePin still returns failure
>
> I added LockPin and UnlockPin methods to take care of these two cases.

Should we have a read-only property so clients know what the current
state is?  Unfortunately this would be some 6 properties and 6 more
commands on startup, for little gain.  I attached a diff to add plugin
interface for this without dbus interface.  The other two changes are
just clean-up.

Regards

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Update-sim-api.txt-ChangePin-no-longer-disables-pin.patch --]
[-- Type: text/x-patch, Size: 751 bytes --]

From 8f63f7860271f634a5106f68d10ff7331343dea5 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Wed, 23 Sep 2009 23:17:06 +0200
Subject: [PATCH] Update sim-api.txt: ChangePin no longer disables pin.

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

diff --git a/doc/sim-api.txt b/doc/sim-api.txt
index caf2dc4..f87dbeb 100644
--- a/doc/sim-api.txt
+++ b/doc/sim-api.txt
@@ -14,8 +14,7 @@ Methods		dict GetProperties()
 
 		ChangePin(string type, string oldpin, string newpin)
 
-			Changes the pin given by string type.  If newpin is
-			empty, this has the effect of disabling the pin.
+			Changes the pin given by string type.
 
 		EnterPin(string type, string pin)
 
-- 
1.6.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0003-Add-a-plugin-interface-for-getting-PIN-lock-state.patch --]
[-- Type: text/x-patch, Size: 3494 bytes --]

From ab0131e797fe09049b31beb2a1bf622515eab78f Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Thu, 24 Sep 2009 00:33:28 +0200
Subject: [PATCH] Add plugin interface for getting PIN lock state.

It may be useful to have the information of whether card is currently
locked and emit events when this changes but if we want to have it as a
property, we would need properties for all types of locks and it wouldn't
be all that useful.
---
 drivers/atmodem/sim.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sim.h         |    6 +++++
 2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index b7d8368..d04b736 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -634,6 +634,66 @@ error:
 	CALLBACK_WITH_FAILURE(cb, data);
 }
 
+static void at_lock_status_cb(gboolean ok, GAtResult *result,
+		gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	GAtResultIter iter;
+	ofono_sim_locked_cb_t cb = cbd->cb;
+	struct ofono_error error;
+	int locked;
+
+	dump_response("at_lock_status_cb", ok, result);
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CLCK:")) {
+		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_next_number(&iter, &locked);
+
+	ofono_debug("lock_status_cb: %i", locked);
+
+	cb(&error, locked, cbd->data);
+}
+
+static void at_pin_query_enabled(struct ofono_sim *sim,
+				enum ofono_sim_password_type passwd_type,
+				ofono_sim_locked_cb_t cb, void *data)
+{
+	GAtChat *chat = ofono_sim_get_data(sim);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[64];
+	unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
+
+	if (!cbd)
+		goto error;
+
+	if (passwd_type >= len || !at_clck_cpwd_fac[passwd_type])
+		goto error;
+
+	snprintf(buf, sizeof(buf), "AT+CLCK=\"%s\",2",
+			at_clck_cpwd_fac[passwd_type]);
+
+	if (g_at_chat_send(chat, buf, NULL,
+				at_lock_status_cb, cbd, g_free) > 0)
+		return;
+
+error:
+	if (cbd)
+		g_free(cbd);
+
+	CALLBACK_WITH_FAILURE(cb, -1, data);
+}
+
 static gboolean at_sim_register(gpointer user)
 {
 	struct ofono_sim *sim = user;
@@ -675,6 +735,7 @@ static struct ofono_sim_driver driver = {
 	.reset_passwd		= at_pin_send_puk,
 	.lock			= at_pin_enable,
 	.change_passwd		= at_change_passwd,
+	.query_locked		= at_pin_query_enabled,
 };
 
 void at_sim_init()
diff --git a/include/sim.h b/include/sim.h
index af2fd1e..fa5276b 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -91,6 +91,9 @@ typedef void (*ofono_sim_passwd_cb_t)(const struct ofono_error *error,
 typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
 					void *data);
 
+typedef void (*ofono_sim_locked_cb_t)(const struct ofono_error *error,
+					int locked, void *data);
+
 struct ofono_sim_driver {
 	const char *name;
 	int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
@@ -131,6 +134,9 @@ struct ofono_sim_driver {
 	void (*lock)(struct ofono_sim *sim, enum ofono_sim_password_type type,
 			int enable, const char *passwd,
 			ofono_sim_lock_unlock_cb_t cb, void *data);
+	void (*query_locked)(struct ofono_sim *sim,
+			enum ofono_sim_password_type type,
+			ofono_sim_locked_cb_t cb, void *data);
 };
 
 int ofono_sim_driver_register(const struct ofono_sim_driver *d);
-- 
1.6.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0004-Remove-unused-struct-field.patch --]
[-- Type: text/x-patch, Size: 655 bytes --]

From 35546966ef1107115003481928aa12d6b472ce7d Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Thu, 24 Sep 2009 00:35:15 +0200
Subject: [PATCH] Remove unused struct field.

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

diff --git a/src/sim.c b/src/sim.c
index ec003ee..746c7a8 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -86,7 +86,6 @@ struct ofono_sim {
 	unsigned char efmsisdn_records;
 	unsigned char *efli;
 	unsigned char efli_length;
-	unsigned int next_ready_watch_id;
 	struct ofono_watchlist *ready_watches;
 	const struct ofono_sim_driver *driver;
 	void *driver_data;
-- 
1.6.1


  reply	other threads:[~2009-09-23 20:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-05  7:25 [PATCH] [RFC] Do the PIN check in SIMManager Andrzej Zaborowski
2009-09-07  9:53 ` Santtu Lakkala
2009-09-08  2:41   ` Andrzej Zaborowski
2009-09-17 18:57     ` Andrzej Zaborowski
2009-09-22  5:12       ` Denis Kenzior
2009-09-23 20:47         ` andrzej zaborowski [this message]
2009-09-23 20:02           ` 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=fb249edb0909231347ha981387ge221b34f1e2e4839@mail.gmail.com \
    --to=balrogg@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 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.