From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 7/7] cdma-netreg: Add provider name support
Date: Thu, 24 Nov 2011 17:55:08 -0600 [thread overview]
Message-ID: <4ECED95C.3000900@gmail.com> (raw)
In-Reply-To: <1322156784-10402-8-git-send-email-philippe.nunes@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4308 bytes --]
Hi Philippe,
On 11/24/2011 11:46 AM, Philippe Nunes wrote:
> ---
> Makefile.am | 3 ++-
> src/cdma-netreg.c | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 32 insertions(+), 1 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 6002eb0..978ac9f 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -275,7 +275,8 @@ builtin_sources += drivers/atmodem/atutil.h \
> drivers/cdmamodem/voicecall.c \
> drivers/cdmamodem/devinfo.c \
> drivers/cdmamodem/connman.c \
> - drivers/cdmamodem/network-registration.c
> + drivers/cdmamodem/network-registration.c \
> + plugins/mbpi.c plugins/mbpi.h
> endif
>
> builtin_modules += g1
> diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
> index 222c3b7..19947ab 100644
> --- a/src/cdma-netreg.c
> +++ b/src/cdma-netreg.c
> @@ -28,6 +28,7 @@
> #include <gdbus.h>
>
> #include "ofono.h"
> +#include "plugins/mbpi.h"
Don't do this, see below
>
> static GSList *g_drivers;
>
> @@ -38,6 +39,7 @@ struct ofono_cdma_netreg {
> const struct ofono_cdma_netreg_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> + char *provider_name;
> };
>
> static const char *cdma_netreg_status_to_string(enum cdma_netreg_status status)
> @@ -90,6 +92,10 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
> &strength);
> }
>
> + if (cdma_netreg->provider_name)
> + ofono_dbus_dict_append(&dict, "Name", DBUS_TYPE_STRING,
> + &cdma_netreg->provider_name);
> +
You might also want to export the SystemIdentifier property here
> dbus_message_iter_close_container(&iter, &dict);
>
> return reply;
> @@ -108,6 +114,9 @@ static void serving_system_callback(const struct ofono_error *error,
> const char *sid, void *data)
> {
> struct ofono_cdma_netreg *cdma_netreg = data;
> + const char *path = __ofono_atom_get_path(cdma_netreg->atom);
> + DBusConnection *conn = ofono_dbus_get_connection();
> + GError *err = NULL;
>
> if (cdma_netreg->status != CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
> && cdma_netreg->status !=
> @@ -120,6 +129,20 @@ static void serving_system_callback(const struct ofono_error *error,
> }
>
> DBG("Serving system Identifier: %s", sid);
> +
> + g_free(cdma_netreg->provider_name);
> + cdma_netreg->provider_name = NULL;
> + cdma_netreg->provider_name = mbpi_lookup_cdma_provider_name(sid, &err);
Please don't do it this way, this part should be abstracted behind a
provider name lookup plugin, similar to how context provisioning for GSM
is done. Mobile Broadband Provider Info database might not be the only
source of this information, in fact manufacturers might have their own
(better) databases.
> +
> + if (cdma_netreg->provider_name)
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
> + "Name", DBUS_TYPE_STRING,
> + &cdma_netreg->provider_name);
> + else if (err != NULL) {
> + ofono_error("%s", err->message);
> + g_error_free(err);
> + }
Are you sure you want to perform the lookup every time? Why don't you
cache the last result and not perform the query if the SID is the same
as the last one obtained. We're highly unlikely to get a different SID
under normal circumstances (e.g. signal loss, etc) so re-querying seems
wasteful.
> }
>
> static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
> @@ -136,6 +159,12 @@ static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
> "Status", DBUS_TYPE_STRING,
> &str_status);
>
> + if (cdma_netreg->status ==
> + CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED) {
> + g_free(cdma_netreg->provider_name);
> + cdma_netreg->provider_name = NULL;
See comment above
> + }
> +
> if (cdma_netreg->status == CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
> || cdma_netreg->status ==
> CDMA_NETWORK_REGISTRATION_STATUS_ROAMING)
> @@ -251,6 +280,7 @@ static void cdma_netreg_remove(struct ofono_atom *atom)
> if (cdma_netreg->driver && cdma_netreg->driver->remove)
> cdma_netreg->driver->remove(cdma_netreg);
>
> + g_free(cdma_netreg->provider_name);
> g_free(cdma_netreg);
> }
>
Regards,
-Denis
prev parent reply other threads:[~2011-11-24 23:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 17:46 [PATCH 0/7] Get SID and provider name Philippe Nunes
2011-11-24 17:46 ` [PATCH 1/7] Huaweicdmamodem: remove this specific driver Philippe Nunes
2011-11-24 17:46 ` [PATCH 2/7] huaweicdmamodem: Merge this driver with cdmamodem driver Philippe Nunes
2011-11-24 17:46 ` [PATCH 3/7] cdmamodem: Add CDMA network-registration support Philippe Nunes
2011-11-24 17:46 ` [PATCH 4/7] cdma-netreg: Add 'serving_system' entry point to cdma-netreg to get SID Philippe Nunes
2011-11-24 23:42 ` Denis Kenzior
2011-11-24 17:46 ` [PATCH 5/7] cdmamodem: Add serving system identifier support Philippe Nunes
2011-11-24 17:46 ` [PATCH 6/7] cdma-netreg: Make use of the new driver entry point serving_system Philippe Nunes
2011-11-24 23:51 ` Denis Kenzior
2011-11-24 17:46 ` [PATCH 7/7] cdma-netreg: Add provider name support Philippe Nunes
2011-11-24 23:55 ` Denis Kenzior [this message]
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=4ECED95C.3000900@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 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.