Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 7/9] message-waiting: Watch for changes to relevant SIM files.
Date: Thu, 17 Feb 2011 14:54:47 -0600	[thread overview]
Message-ID: <4D5D8B17.70303@gmail.com> (raw)
In-Reply-To: <1297756739-2958-7-git-send-email-andrew.zaborowski@intel.com>

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

Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/message-waiting.c |   88 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 87 insertions(+), 1 deletions(-)
> 
> diff --git a/src/message-waiting.c b/src/message-waiting.c
> index 72cf582..f5406ca 100644
> --- a/src/message-waiting.c
> +++ b/src/message-waiting.c
> @@ -576,6 +576,33 @@ static void mw_mbdn_read_cb(int ok, int total_length, int record,
>  	mw->efmbdn_length = record_length;
>  }
>  
> +static void mw_mbdn_changed(int id, void *userdata)
> +{
> +	struct ofono_message_waiting *mw = userdata;
> +	int err;
> +
> +	mw->efmbdn_length = 0;
> +	mw->mbdn_not_provided = FALSE;
> +
> +	err = ofono_sim_read(mw->sim_context, SIM_EFMBDN_FILEID,
> +				OFONO_SIM_FILE_STRUCTURE_FIXED,
> +				mw_mbdn_read_cb, mw);
> +	if (err != 0)
> +		ofono_error("Unable to read EF-MBDN from SIM");
> +}
> +
> +static void mw_cphs_mbdn_changed(int id, void *userdata)
> +{
> +	struct ofono_message_waiting *mw = userdata;
> +
> +	mw->ef_cphs_mbdn_length = 0;
> +	mw->cphs_mbdn_not_provided = FALSE;
> +
> +	ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MBDN_FILEID,
> +			OFONO_SIM_FILE_STRUCTURE_FIXED,
> +			mw_cphs_mbdn_read_cb, mw);
> +}
> +
>  static void mw_mbi_read_cb(int ok, int total_length, int record,
>  				const unsigned char *data,
>  				int record_length, void *userdata)
> @@ -604,6 +631,8 @@ static void mw_mbi_read_cb(int ok, int total_length, int record,
>  	err = ofono_sim_read(mw->sim_context, SIM_EFMBDN_FILEID,
>  				OFONO_SIM_FILE_STRUCTURE_FIXED,
>  				mw_mbdn_read_cb, mw);
> +	ofono_sim_add_file_watch(mw->sim_context, SIM_EFMBDN_FILEID,
> +					mw_mbdn_changed, mw, NULL);
>  
>  	if (err != 0)
>  		ofono_error("Unable to read EF-MBDN from SIM");
> @@ -615,10 +644,14 @@ out:
>  	 */
>  	st = ofono_sim_get_cphs_service_table(mw->sim);
>  
> -	if (st && bit_field(st[0], 4, 2) == 3)
> +	if (st && bit_field(st[0], 4, 2) == 3) {
>  		ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MBDN_FILEID,
>  				OFONO_SIM_FILE_STRUCTURE_FIXED,
>  				mw_cphs_mbdn_read_cb, mw);
> +		ofono_sim_add_file_watch(mw->sim_context,
> +						SIM_EF_CPHS_MBDN_FILEID,
> +						mw_cphs_mbdn_changed, mw, NULL);
> +	}
>  }
>  
>  static void mw_mwis_write_cb(int ok, void *userdata)
> @@ -935,6 +968,46 @@ static void message_waiting_unregister(struct ofono_atom *atom)
>  	ofono_modem_remove_interface(modem, OFONO_MESSAGE_WAITING_INTERFACE);
>  }
>  
> +static void mw_mwis_changed(int id, void *userdata)
> +{
> +	struct ofono_message_waiting *mw = userdata;
> +
> +	mw->efmwis_length = 0;
> +
> +	ofono_sim_read(mw->sim_context, SIM_EFMWIS_FILEID,
> +			OFONO_SIM_FILE_STRUCTURE_FIXED,
> +			mw_mwis_read_cb, mw);
> +}
> +
> +static void mw_cphs_mwis_changed(int id, void *userdata)
> +{
> +	struct ofono_message_waiting *mw = userdata;
> +
> +	mw->ef_cphs_mwis_length = 0;
> +
> +	ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MWIS_FILEID,
> +			OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
> +			mw_cphs_mwis_read_cb, mw);
> +}
> +
> +static void mw_mbi_changed(int id, void *userdata)
> +{
> +	struct ofono_message_waiting *mw = userdata;
> +
> +	mw->efmbdn_length = 0;
> +	mw->mbdn_not_provided = FALSE;
> +
> +	mw->ef_cphs_mbdn_length = 0;
> +	mw->cphs_mbdn_not_provided = FALSE;
> +
> +	ofono_sim_remove_file_watch(mw->sim_context, SIM_EFMBDN_FILEID);
> +	ofono_sim_remove_file_watch(mw->sim_context, SIM_EF_CPHS_MBDN_FILEID);

This won't actually work, the id returned by add_file_watch and taken by
remove_file_watch is just an unsigned int.  Not the id of the watched
file.  In theory we can try to make it work this way, but it doesn't
right now.

> +
> +	ofono_sim_read(mw->sim_context, SIM_EFMBI_FILEID,
> +			OFONO_SIM_FILE_STRUCTURE_FIXED,
> +			mw_mbi_read_cb, mw);
> +}
> +
>  void ofono_message_waiting_register(struct ofono_message_waiting *mw)
>  {
>  	DBusConnection *conn;
> @@ -980,6 +1053,19 @@ void ofono_message_waiting_register(struct ofono_message_waiting *mw)
>  		ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MWIS_FILEID,
>  				OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
>  				mw_cphs_mwis_read_cb, mw);
> +
> +		/*
> +		 * The operator could send us SMS mwi updates, but let's be
> +		 * extra careful and track the file contents too.
> +		 */
> +		ofono_sim_add_file_watch(mw->sim_context, SIM_EFMWIS_FILEID,
> +						mw_mwis_changed, mw, NULL);
> +		ofono_sim_add_file_watch(mw->sim_context,
> +						SIM_EF_CPHS_MWIS_FILEID,
> +						mw_cphs_mwis_changed, mw, NULL);
> +
> +		ofono_sim_add_file_watch(mw->sim_context, SIM_EFMBI_FILEID,
> +						mw_mbi_changed, mw, NULL);
>  	}
>  
>  	__ofono_atom_register(mw->atom, message_waiting_unregister);

Regards,
-Denis

  reply	other threads:[~2011-02-17 20:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15  7:58 [PATCH 1/9] modem.c: Go to PRE_SIM modem state on OFONO_SIM_STATE_INSERTED Andrzej Zaborowski
2011-02-15  7:58 ` [PATCH 2/9] sim: Implement basic Refresh Andrzej Zaborowski
2011-02-17 21:03   ` Denis Kenzior
2011-02-19  4:18     ` Andrzej Zaborowski
2011-02-15  7:58 ` [PATCH 3/9] sim: Watch for changes to relevant SIM files Andrzej Zaborowski
2011-02-17 21:08   ` Denis Kenzior
2011-02-19  4:24     ` Andrzej Zaborowski
2011-02-15  7:58 ` [PATCH 4/9] voicecall: " Andrzej Zaborowski
2011-02-17 21:08   ` Denis Kenzior
2011-02-15  7:58 ` [PATCH 5/9] network: " Andrzej Zaborowski
2011-02-17 21:09   ` Denis Kenzior
2011-02-15  7:58 ` [PATCH 6/9] cbs: " Andrzej Zaborowski
2011-02-17 21:10   ` Denis Kenzior
2011-02-15  7:58 ` [PATCH 7/9] message-waiting: " Andrzej Zaborowski
2011-02-17 20:54   ` Denis Kenzior [this message]
2011-02-15  7:58 ` [PATCH 8/9] call-forwarding: " Andrzej Zaborowski
2011-02-17 20:57   ` Denis Kenzior
2011-02-15  7:58 ` [PATCH 9/9] stk: Partially handle Refresh command Andrzej Zaborowski
2011-02-17 21:17   ` Denis Kenzior
2011-02-17 21:00 ` [PATCH 1/9] modem.c: Go to PRE_SIM modem state on OFONO_SIM_STATE_INSERTED 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=4D5D8B17.70303@gmail.com \
    --to=denkenz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox