From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/4] radio settings: add FastDormancy property
Date: Wed, 20 Oct 2010 18:07:52 -0500 [thread overview]
Message-ID: <4CBF7648.4030100@gmail.com> (raw)
In-Reply-To: <1286458653-12096-3-git-send-email-mika.liljeberg@nokia.com>
[-- Attachment #1: Type: text/plain, Size: 7077 bytes --]
Hi Mika,
On 10/07/2010 08:37 AM, Mika Liljeberg wrote:
> ---
> include/radio-settings.h | 14 ++++++
> src/radio-settings.c | 104 +++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 117 insertions(+), 1 deletions(-)
>
> diff --git a/include/radio-settings.h b/include/radio-settings.h
> index d41ec0b..20c2a51 100644
> --- a/include/radio-settings.h
> +++ b/include/radio-settings.h
> @@ -42,6 +42,13 @@ typedef void (*ofono_radio_settings_rat_mode_set_cb_t)(const struct ofono_error
> typedef void (*ofono_radio_settings_rat_mode_query_cb_t)(const struct ofono_error *error,
> enum ofono_radio_access_mode mode,
> void *data);
> +typedef void (*ofono_radio_settings_fast_dormancy_set_cb_t)(
> + const struct ofono_error *error,
> + void *data);
> +typedef void (*ofono_radio_settings_fast_dormancy_query_cb_t)(
> + const struct ofono_error *error,
> + ofono_bool_t enable,
> + void *data);
>
> struct ofono_radio_settings_driver {
> const char *name;
> @@ -55,6 +62,13 @@ struct ofono_radio_settings_driver {
> enum ofono_radio_access_mode mode,
> ofono_radio_settings_rat_mode_set_cb_t cb,
> void *data);
> + void (*query_fast_dormancy)(struct ofono_radio_settings *rs,
> + ofono_radio_settings_fast_dormancy_query_cb_t cb,
> + void *data);
> + void (*set_fast_dormancy)(struct ofono_radio_settings *rs,
> + ofono_bool_t enable,
> + ofono_radio_settings_fast_dormancy_set_cb_t,
> + void *data);
> };
>
> int ofono_radio_settings_driver_register(const struct ofono_radio_settings_driver *d);
> diff --git a/src/radio-settings.c b/src/radio-settings.c
> index 5b6ef9e..e6f0980 100644
> --- a/src/radio-settings.c
> +++ b/src/radio-settings.c
> @@ -33,7 +33,9 @@
> #include "ofono.h"
> #include "common.h"
>
> -#define RADIO_SETTINGS_MODE_CACHED 0x1
> +#define RADIO_SETTINGS_MODE_CACHED 0x01
> +#define FAST_DORMANCY_SETTING_CACHED 0x02
> +
As mentioned in the previous email, a single cached flag is enough.
>
> static GSList *g_drivers = NULL;
>
> @@ -42,6 +44,8 @@ struct ofono_radio_settings {
> int flags;
> int mode;
> int pending_mode;
> + ofono_bool_t fast_dormancy_current;
> + ofono_bool_t fast_dormancy_target;
can you rename this into fast_dormancy and fast_dormancy_pending?
> const struct ofono_radio_settings_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> @@ -80,6 +84,9 @@ static int string_to_radio_access_mode(const char *mode)
> static void radio_rat_mode_query_callback(const struct ofono_error *error,
> enum ofono_radio_access_mode mode,
> void *data);
> +static void fast_dormancy_query_callback(const struct ofono_error *error,
> + ofono_bool_t enable,
> + void *data);
>
> static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
> struct ofono_radio_settings *rs)
> @@ -110,6 +117,17 @@ static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
> return NULL;
> }
>
> + if (rs->flags & FAST_DORMANCY_SETTING_CACHED) {
> + dbus_bool_t value = rs->fast_dormancy_current;
> + ofono_dbus_dict_append(&dict, "FastDormancy",
> + DBUS_TYPE_BOOLEAN, &value);
In patch 3 you note that this property is optional. Am I missing
something or it is always included in the dictionary?
> + } else if (rs->driver->query_fast_dormancy) {
> + rs->driver->query_fast_dormancy(rs,
> + fast_dormancy_query_callback, rs);
> + dbus_message_unref(reply);
> + return NULL;
> + }
> +
> dbus_message_iter_close_container(&iter, &dict);
>
> return reply;
> @@ -175,6 +193,67 @@ static void radio_rat_mode_query_callback(const struct ofono_error *error,
> __ofono_dbus_pending_reply(&rs->pending, reply);
> }
>
> +static void set_fast_dormancy(struct ofono_radio_settings *rs,
> + ofono_bool_t enable)
> +{
> + if ((rs->flags & FAST_DORMANCY_SETTING_CACHED) &&
> + rs->fast_dormancy_current != enable) {
> +
> + DBusConnection *conn = ofono_dbus_get_connection();
> + const char *path = __ofono_atom_get_path(rs->atom);
> + dbus_bool_t value = enable;
> +
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_RADIO_SETTINGS_INTERFACE,
> + "FastDormancy",
> + DBUS_TYPE_BOOLEAN, &value);
> + }
> +
> + rs->fast_dormancy_current = enable;
> + rs->flags |= FAST_DORMANCY_SETTING_CACHED;
> +}
> +
> +static void fast_dormancy_set_callback(const struct ofono_error *error,
> + void *data)
> +{
> + struct ofono_radio_settings *rs = data;
> + DBusMessage *reply;
> +
> + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
> + DBG("Error setting fast dormancy");
> + rs->fast_dormancy_target = rs->fast_dormancy_current;
> + reply = __ofono_error_failed(rs->pending);
> + __ofono_dbus_pending_reply(&rs->pending, reply);
> + return;
> + }
> +
> + reply = dbus_message_new_method_return(rs->pending);
> + __ofono_dbus_pending_reply(&rs->pending, reply);
> +
> + set_fast_dormancy(rs, rs->fast_dormancy_target);
> +}
> +
> +static void fast_dormancy_query_callback(const struct ofono_error *error,
> + ofono_bool_t enable,
> + void *data)
> +{
> + struct ofono_radio_settings *rs = data;
> + DBusMessage *reply;
> +
> + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
> + DBG("Error during fast dormancy query");
> + reply = __ofono_error_failed(rs->pending);
> + __ofono_dbus_pending_reply(&rs->pending, reply);
> + return;
> + }
> +
> + set_fast_dormancy(rs, enable);
> +
> + reply = radio_get_properties_reply(rs->pending, rs);
> + if (reply)
> + __ofono_dbus_pending_reply(&rs->pending, reply);
> +}
> +
Can you restructure the rest of the code according to comments in the
previous email? E.g. on a get_properties: query rat, then query
dormancy and set cached flag. Skip any queries which are not supported
by the driver.
> static DBusMessage *radio_get_properties(DBusConnection *conn, DBusMessage *msg,
> void *data)
> {
> @@ -236,6 +315,29 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
> rs->driver->set_rat_mode(rs, mode, radio_mode_set_callback, rs);
>
> return NULL;
> + } else if (g_strcmp0(property, "FastDormancy") == 0) {
> + dbus_bool_t value;
> + ofono_bool_t target;
> +
> + if (!rs->driver->set_fast_dormancy)
> + return __ofono_error_not_implemented(msg);
> +
> + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
> + return __ofono_error_invalid_args(msg);
> +
> + dbus_message_iter_get_basic(&var, &value);
> + target = value;
> +
> + if (rs->fast_dormancy_target == target)
> + return dbus_message_new_method_return(msg);
> +
> + rs->pending = dbus_message_ref(msg);
> + rs->fast_dormancy_target = target;
> +
> + rs->driver->set_fast_dormancy(rs, target,
> + fast_dormancy_set_callback, rs);
> +
> + return NULL;
This part looks good
> }
>
> return __ofono_error_invalid_args(msg);
Regards,
-Denis
next prev parent reply other threads:[~2010-10-20 23:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 13:37 [PATCH 0/4] Support for fast dormancy - take 2 Mika Liljeberg
2010-10-07 13:37 ` [PATCH 1/4] radio settings: allow for more than one property Mika Liljeberg
2010-10-20 22:57 ` Denis Kenzior
2010-10-21 8:55 ` Mika.Liljeberg
2010-10-21 14:03 ` Denis Kenzior
2010-10-22 7:08 ` Mika.Liljeberg
2010-10-22 13:49 ` Denis Kenzior
2010-10-22 14:21 ` Mika.Liljeberg
2010-10-22 14:55 ` Denis Kenzior
2010-10-25 6:59 ` Mika.Liljeberg
2010-10-07 13:37 ` [PATCH 2/4] radio settings: add FastDormancy property Mika Liljeberg
2010-10-20 23:07 ` Denis Kenzior [this message]
2010-10-07 13:37 ` [PATCH 3/4] radio settings: document " Mika Liljeberg
2010-10-07 15:34 ` Marcel Holtmann
2010-10-08 6:56 ` Mika.Liljeberg
2010-10-08 8:55 ` Marcel Holtmann
2010-10-20 23:21 ` Denis Kenzior
2010-10-07 13:37 ` [PATCH 4/4] test: add scripts to enable and disable fast dormancy Mika Liljeberg
2010-10-20 23:09 ` Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2010-10-07 13:21 [PATCH 0/4] Support for fast formancy Mika Liljeberg
2010-10-07 13:21 ` [PATCH 2/4] radio settings: add FastDormancy property Mika Liljeberg
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=4CBF7648.4030100@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