* [PATCH 3/3] If EF-MWIS is not available use the CPHS version.
@ 2010-01-07 11:39 Andrzej Zaborowski
2010-01-13 0:23 ` Denis Kenzior
0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Zaborowski @ 2010-01-07 11:39 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4895 bytes --]
---
src/message-waiting.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++--
src/simutil.h | 1 +
2 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/src/message-waiting.c b/src/message-waiting.c
index 283c5e2..05d05ed 100644
--- a/src/message-waiting.c
+++ b/src/message-waiting.c
@@ -51,6 +51,7 @@ struct ofono_message_waiting {
unsigned char efmwis_length;
unsigned char efmbdn_length;
unsigned char efmbdn_record_id[5];
+ unsigned char ef_cphs_mwis_length;
unsigned char ef_cphs_mbdn_length;
gboolean mbdn_not_provided;
struct ofono_phone_number mailbox_number[5];
@@ -478,6 +479,60 @@ static void mw_mbi_read_cb(int ok, int total_length, int record,
ofono_error("Unable to read EF-MBDN from SIM");
}
+static void mw_cphs_mwis_read_cb(int ok, int total_length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_message_waiting *mw = userdata;
+ int i;
+ struct mailbox_state info;
+ dbus_bool_t indication;
+ unsigned char count;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(mw->atom);
+
+ if (!ok || total_length < 1) {
+ ofono_error("Unable to read waiting messages indicator "
+ "status from SIM");
+
+ mw->ef_cphs_mwis_length = 0;
+
+ return;
+ }
+
+ mw->ef_cphs_mwis_length = total_length;
+
+ if (mw->efmwis_length != 0)
+ return;
+
+ for (i = 0; i < 5 && i < total_length; i++) {
+ info.indication = (data[i] == 0xa);
+ info.message_count = 0;
+
+ if (mw->messages[i].indication != info.indication ||
+ mw->messages[i].message_count !=
+ info.message_count) {
+ memcpy(&mw->messages[i], &info, sizeof(info));
+
+ indication = info.indication;
+ count = info.message_count;
+
+ if (!mw_message_waiting_property_name[i])
+ continue;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ MESSAGE_WAITING_INTERFACE,
+ mw_message_waiting_property_name[i],
+ DBUS_TYPE_BOOLEAN, &indication);
+
+ ofono_dbus_signal_property_changed(conn, path,
+ MESSAGE_WAITING_INTERFACE,
+ mw_message_count_property_name[i],
+ DBUS_TYPE_BYTE, &count);
+ }
+ }
+}
+
static void mw_cphs_mbdn_read_cb(int ok, int total_length, int record,
const unsigned char *data,
int record_length, void *userdata)
@@ -526,7 +581,7 @@ static void mw_cphs_mbdn_read_cb(int ok, int total_length, int record,
static void mw_mwis_write_cb(int ok, void *userdata)
{
if (!ok)
- ofono_error("Writing new EF-MBDN failed");
+ ofono_error("Writing new EF-MWIS failed");
}
static void mw_set_indicator(struct ofono_message_waiting *mw, int profile,
@@ -575,7 +630,10 @@ static void mw_set_indicator(struct ofono_message_waiting *mw, int profile,
}
/* Writes MWI states and/or MBDN back to SIM */
- if ((mw->efmwis_length < 5)) {
+ if (mw->efmwis_length < 5) {
+ if (mw->ef_cphs_mwis_length >= 1)
+ goto try_cphs;
+
ofono_error("Unable to update MWIS indicator");
return;
}
@@ -594,6 +652,18 @@ static void mw_set_indicator(struct ofono_message_waiting *mw, int profile,
efmwis, mw->efmwis_length, mw) != 0) {
ofono_error("Queuing a EF-MWI write to SIM failed");
}
+
+ if (mw->ef_cphs_mwis_length == 0)
+ return;
+
+try_cphs:
+ for (i = 0; i < 5 && i < mw->ef_cphs_mwis_length; i++)
+ efmwis[i] = mw->messages[i].indication ? 0xa : 0x5;
+
+ if (ofono_sim_write(mw->sim, SIM_EF_CPHS_MWIS_FILEID, mw_mwis_write_cb,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, 0,
+ efmwis, mw->ef_cphs_mwis_length, mw) != 0)
+ ofono_error("Queuing a EF-MWIS write to SIM failed (CPHS)");
}
static void handle_special_sms_iei(struct ofono_message_waiting *mw,
@@ -835,12 +905,17 @@ void ofono_message_waiting_register(struct ofono_message_waiting *mw)
ofono_sim_read(mw->sim, SIM_EFMBI_FILEID,
OFONO_SIM_FILE_STRUCTURE_FIXED,
mw_mbi_read_cb, mw);
+
if ((ofono_sim_get_cphs_support(mw->sim) &
OFONO_SIM_CPHS_ST_MAILBOX_NUMBERS_MASK) ==
- OFONO_SIM_CPHS_ST_MAILBOX_NUMBERS_MASK)
+ OFONO_SIM_CPHS_ST_MAILBOX_NUMBERS_MASK) {
+ ofono_sim_read(mw->sim, SIM_EF_CPHS_MWIS_FILEID,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+ mw_cphs_mwis_read_cb, mw);
ofono_sim_read(mw->sim, SIM_EF_CPHS_MBDN_FILEID,
OFONO_SIM_FILE_STRUCTURE_FIXED,
mw_cphs_mbdn_read_cb, mw);
+ }
}
__ofono_atom_register(mw->atom, message_waiting_unregister);
diff --git a/src/simutil.h b/src/simutil.h
index 0fedab9..5c28512 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -22,6 +22,7 @@
enum sim_fileid {
SIM_EFPL_FILEID = 0x2f05,
SIM_EFLI_FILEID = 0x6f05,
+ SIM_EF_CPHS_MWIS_FILEID = 0x6f11,
SIM_EF_CPHS_INFORMATION_FILEID = 0x6f16,
SIM_EF_CPHS_MBDN_FILEID = 0x6f17,
SIM_EFMSISDN_FILEID = 0x6f40,
--
1.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 3/3] If EF-MWIS is not available use the CPHS version.
2010-01-07 11:39 [PATCH 3/3] If EF-MWIS is not available use the CPHS version Andrzej Zaborowski
@ 2010-01-13 0:23 ` Denis Kenzior
2010-01-13 1:24 ` andrzej zaborowski
0 siblings, 1 reply; 3+ messages in thread
From: Denis Kenzior @ 2010-01-13 0:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
Hi Andrew,
I applied this patch, but really it was completely broken and I shouldn't
have. I ended up rewriting most of it since the CPHS MWIS format is
completely different from 3GPP.
Please test and make sure my changes are correct.
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3/3] If EF-MWIS is not available use the CPHS version.
2010-01-13 0:23 ` Denis Kenzior
@ 2010-01-13 1:24 ` andrzej zaborowski
0 siblings, 0 replies; 3+ messages in thread
From: andrzej zaborowski @ 2010-01-13 1:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
Hi Denis,
2010/1/13 Denis Kenzior <denkenz@gmail.com>:
> I applied this patch, but really it was completely broken and I shouldn't
You're right. I had passed a NULL in place of user data for
ofono_sim_write due to a last-minute refactoring, sorry about that.
No recurrence was possible though because of a check that new and old
MBDNs were different.
> have. I ended up rewriting most of it since the CPHS MWIS format is
> completely different from 3GPP.
The new version works for me. My patch had the fax indication in the
wrong byte because as you noticed there's no separate fax or data MWI
for the second ALS line.
Regards
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-13 1:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-07 11:39 [PATCH 3/3] If EF-MWIS is not available use the CPHS version Andrzej Zaborowski
2010-01-13 0:23 ` Denis Kenzior
2010-01-13 1:24 ` andrzej zaborowski
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.