Implement writing EF-MBDN on SetProperty or Enhanced Voicemail IE.
PATCH 1/1 Implement writing EF-MBDN on SetProperty or Enhanced Voicemail IE.
I've not tested this on a real SIM yet.
--- src/message-waiting.c | 51 ++++++++++++++++++++++++++++++++++++------------ src/simutil.c | 27 +++++++++++++++++++++++++ src/simutil.h | 2 + src/smsutil.c | 47 +++++++++++++++++++++++++++++--------------- src/smsutil.h | 8 +++++++ 5 files changed, 106 insertions(+), 29 deletions(-)
src/message-waiting.c +38 -13
@@ -164,12 +164,12 @@ static DBusMessage *mw_get_properties(DBusConnection *conn,return reply; } -static void mbdn_set_cb (gboolean ok,void *data) +static void mbdn_set_cb (struct ofono_modem *modem,int ok,void *data) {struct mbdn_set_request *req = data;struct ofono_phone_number *old = &req->mw->mailbox_number[req->mailbox];const char *property; -DBusMessage *reply; +DBusMessage *reply =0 ;/* Quiet a warning */ if (!ok) {if (req->msg)
@@ -208,11 +208,19 @@ out:g_free (req); } -static void set_mbdn (struct ofono_modem *modem,int mailbox, +static DBusMessage *set_mbdn (struct ofono_modem *modem,int mailbox,const char *number,DBusMessage *msg) {DBusConnection *conn =ofono_dbus_get_connection ();struct mbdn_set_request *req; +unsigned char efmbdn[255 ]; + +if (modem->message_waiting->efmbdn_record_id[mailbox] ==0 ) { +if (msg) +return __ofono_error_failed (msg); + +return NULL ; + } req = g_new0(struct mbdn_set_request, 1);
@@ -222,8 +230,19 @@ static void set_mbdn(struct ofono_modem *modem, int mailbox,string_to_phone_number (number, &req->number); req->msg =dbus_message_ref (msg); -/* TODO: Fill the actual sim_write data */ -mbdn_set_cb (TRUE, req); +sim_adn_build (efmbdn, req->mw->efmbdn_length, &req->number); + +if (ofono_sim_write (modem,SIM_EFMBDN_FILEID , mbdn_set_cb, +OFONO_SIM_FILE_STRUCTURE_FIXED , + req->mw->efmbdn_record_id[mailbox], + efmbdn, req->mw->efmbdn_length, req) ==-1 ) { +g_free (req); + +if (msg) +return __ofono_error_failed (msg); + } + +return NULL ; } static DBusMessage *mw_set_property(DBusConnection *conn, DBusMessage *msg,
@@ -275,8 +294,7 @@ static DBusMessage *mw_set_property(DBusConnection *conn, DBusMessage *msg,if (g_str_equal (cur_number, value))return dbus_message_new_method_return (msg); -set_mbdn (modem, i, value, msg); -return NULL ; +return set_mbdn (modem, i, value, msg); }return __ofono_error_invalid_args (msg);
@@ -599,6 +617,7 @@ static void handle_enhanced_voicemail_iei(struct ofono_modem *modem, {int profile, n;gboolean set; +struct sms_address mailbox_address;if (length <3 )return ;
@@ -614,9 +633,10 @@ static void handle_enhanced_voicemail_iei(struct ofono_modem *modem,if (discard) *discard = (iei[0 ] & (1 <<4 )) ? FALSE : TRUE; -/* TODO: VM_MAILBOX_ACCESS_ADDRESS */ - n =2 + (iei[1 ] +1 ) /2 ; -if (length < n +11 ) +/* VM_MAILBOX_ACCESS_ADDRESS */ + n =0 ; +if (!sms_decode_address_field (iei +1 , length -1 , &n, + FALSE, &mailbox_address))return ;/* TODO: VM_MESSAGE_PRIORITY_INDICATION */
@@ -636,9 +656,10 @@ static void handle_enhanced_voicemail_iei(struct ofono_modem *modem,if (discard) *discard = (iei[0 ] & (1 <<4 )) ? FALSE : TRUE; -/* TODO: VM_MAILBOX_ACCESS_ADDRESS */ - n =2 + (iei[1 ] +1 ) /2 ; -if (length < n +11 ) +/* VM_MAILBOX_ACCESS_ADDRESS */ + n =0 ; +if (!sms_decode_address_field (iei +1 , length -1 , &n, + FALSE, &mailbox_address))return ;/* Other parameters currently not supported */
@@ -647,6 +668,10 @@ static void handle_enhanced_voicemail_iei(struct ofono_modem *modem,mw_set_indicator (modem, profile,SMS_MWI_TYPE_VOICE , set, iei[n +2 ]); } + +if (mailbox_address.address[0 ] !='\0' ) +set_mbdn (modem,SMS_MWI_TYPE_VOICE , +sms_address_to_string (&mailbox_address),NULL ); } void ofono_handle_sms_mwi(struct ofono_modem *modem,
src/simutil.c +27 -0
@@ -426,3 +426,30 @@ gboolean sim_adn_parse(const unsigned char *data, int length,return TRUE; } + +void sim_adn_build (unsigned char *data,int length, +const struct ofono_phone_number *ph) +{ +int number_len =strlen (ph->number); + +/* Alpha-Identifier field */ +if (length >14 ) { +memset (data,0xff , length -14 ); + data += length -14 ; + } + + number_len = (number_len +1 ) /2 ; + *data++ = number_len +1 ; + +/* Use given number type and 'Unknown' for Numbering Plan */ + *data++ =0x80 | (ph->type <<4 ) |0 ; + +encode_bcd_number (ph->number, data); +memset (data + number_len,0xff ,10 - number_len); + data +=10 ; + +/* CCP1 unused */ + *data++ =0xff ; +/* Ext1 unused */ + *data++ =0xff ; +}
src/simutil.h +2 -0
@@ -82,3 +82,5 @@ static inline enum sim_file_access file_access_condition_decode(int bcd)gboolean sim_adn_parse (const unsigned char *data,int length,struct ofono_phone_number *ph); +void sim_adn_build (unsigned char *data,int length, +const struct ofono_phone_number *ph);
src/smsutil.c +31 -16
125 lines not on this page · raw message
src/smsutil.h +8 -0
@@ -401,6 +401,7 @@ static inline unsigned char bit_field(unsigned char oct, int start, int num) }void extract_bcd_number (const unsigned char *buf,int len,char *out); +void encode_bcd_number (const char *number,unsigned char *out);gboolean sms_decode (const unsigned char *pdu,int len,gboolean outgoing,int tpdu_len,struct sms *out);
@@ -408,6 +409,13 @@ gboolean sms_decode(const unsigned char *pdu, int len, gboolean outgoing,gboolean sms_encode (const struct sms *in,int *len,int *tpdu_len,unsigned char *pdu); +gboolean sms_decode_address_field (const unsigned char *pdu,int len, +int *offset,gboolean sc, +struct sms_address *out); + +gboolean sms_encode_address_field (const struct sms_address *in,gboolean sc, +unsigned char *pdu,int *offset); +int sms_udl_in_bytes (guint8 ud_len,guint8 dcs);time_t sms_scts_to_time (const struct sms_scts *scts,struct tm *remote);
Signature · 1 line
1.6.1
2009/8/5 Andrzej Zaborowski <[email protected]>:
Quoted 1 line
I've not tested this on a real SIM yet.
It needs the attached fix since the record numbers passed to the plugin are now 1-based.
Regards
From 2b689be0c8cebc773679a60a4103cff29b6b29d5 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Wed, 5 Aug 2009 11:25:21 +0200
Subject: [PATCH] Fix record number in at_sim_update_record.
--- drivers/atmodem/sim.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/atmodem/sim.c +1 -1
@@ -321,7 +321,7 @@ static void at_sim_update_record(struct ofono_modem *modem, int fileid, goto error; len =sprintf (buf,"AT+CRSM=220,%i,%i,4,%i," , fileid, - record +1 , length); + record, length);for (; length; length--) len +=sprintf (buf + len,"%02hhx" , *value++);
Signature · 1 line
1.6.1
Hi,
Quoted 6 lines
2009/8/5 Andrzej Zaborowski <[email protected]>:
Quoted 1 line
I've not tested this on a real SIM yet.
It needs the attached fix since the record numbers passed to the plugin are now 1-based.
Patch has been applied. Thanks.
Regards,
-Denis
Hi Andrew,
Quoted 9 lines
I've not tested this on a real SIM yet.
--- src/message-waiting.c | 51 ++++++++++++++++++++++++++++++++++++------------ src/simutil.c | 27 +++++++++++++++++++++++++ src/simutil.h | 2 + src/smsutil.c | 47 +++++++++++++++++++++++++++++--------------- src/smsutil.h | 8 +++++++ 5 files changed, 106 insertions(+), 29 deletions(-)
I've broken up your patch into several smaller patches, but should be otherwise unchanged. Should now be upstream.
Thanks,
-Denis