Skip to contentSkip to conversation

Provider name and SID

PATCH Superseded Philippe Nunes 2 participants 8 messages Nov 30, 2011 – Dec 1, 2011 Kbuild

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Provider name and SID

With this set of patches:

- cdma-providers.c is introducing an abstracted API to retrieve the provider name from the SID.
This abstraction layer provides the ability to support multiple database for the provider name lookup.
- As an example, the new plugin "providers" is based on the Mobile Broadband Provider Info database.
- The lookup for the provider name is performed only if the system identifier has changed.

Philippe Nunes (5):
cdma-providers: add driver APIs header
ofono.h: add cdma-providers
cdma-providers: add driver APIs implementation
providers: add cdma provider name plugin
cdma-netreg: Add provider name and SID support

 Makefile.am              |    4 +-
 include/cdma-providers.h |   44 +++++++++++++++++++++++++
 plugins/providers.c      |   79 +++++++++++++++++++++++++++++++++++++++++++++
 src/cdma-netreg.c        |   40 +++++++++++++++++++++++
 src/cdma-providers.c     |   80 ++++++++++++++++++++++++++++++++++++++++++++++
 src/ofono.h              |    4 ++
 6 files changed, 249 insertions(+), 2 deletions(-)
 create mode 100644 include/cdma-providers.h
 create mode 100644 plugins/providers.c
 create mode 100644 src/cdma-providers.c
#1 lore raw

PATCH 1/5 cdma-providers: add driver APIs header

---
 include/cdma-providers.h |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
 create mode 100644 include/cdma-providers.h
include/cdma-providers.h new file +44 -0
new file mode 100644
index 0000000..8ee9e1e
@@ -0,0 +1,44 @@
+/*
+ *
+ *  oFono - Open Telephony stack for Linux
+ *
+ *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __OFONO_CDMA_PROVIDERS_H
+#define __OFONO_CDMA_PROVIDERS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ofono_cdma_providers_driver {
+	const char *name;
+	int priority;
+	int (*get_provider_name)(const char *sid, char **name);
+};
+
+int ofono_cdma_providers_driver_register(
+		const struct ofono_cdma_providers_driver *driver);
+void ofono_cdma_providers_driver_unregister(
+		const struct ofono_cdma_providers_driver *driver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CDMA_PROVIDERS_H */
Signature · 1 line
1.7.1
#3 lore raw

PATCH 2/5 ofono.h: add cdma-providers

In reply to Philippe Nunes
---
 src/ofono.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
src/ofono.h +4 -0
index bfb534d..a26c06d 100644
@@ -487,6 +487,10 @@ void __ofono_gprs_provision_free_settings(
 #include <ofono/gnss.h>
 #include <ofono/cdma-sms.h>
 #include <ofono/cdma-netreg.h>
+
+#include <ofono/cdma-providers.h>
+ofono_bool_t __ofono_cdma_providers_get_name(const char *sid, char **name);
+
 #include <ofono/private-network.h>
 
 void __ofono_private_network_release(int id);
Signature · 1 line
1.7.1
#4 lore raw

PATCH 3/5 cdma-providers: add driver APIs implementation

In reply to Philippe Nunes
---
 Makefile.am          |    4 +-
 src/cdma-providers.c |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 src/cdma-providers.c
Makefile.am +2 -2
index 337aeb7..dca9984 100644
@@ -18,7 +18,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
 			include/location-reporting.h \
 			include/cdma-connman.h include/gnss.h \
 			include/private-network.h include/cdma-netreg.h \
-			include/handsfree.h
+			include/cdma-providers.h include/handsfree.h
 
 nodist_pkginclude_HEADERS = include/version.h
 
@@ -430,7 +430,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
 			src/gnssagent.c src/gnssagent.h \
 			src/cdma-smsutil.h src/cdma-smsutil.c \
 			src/cdma-sms.c src/private-network.c src/cdma-netreg.c \
-			src/handsfree.c
+			src/cdma-providers.c src/handsfree.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
src/cdma-providers.c new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw

PATCH 4/5 providers: add cdma provider name plugin

In reply to Philippe Nunes
---
 plugins/providers.c |   79 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 plugins/providers.c
plugins/providers.c new file +79 -0
new file mode 100644
index 0000000..f267db9
@@ -0,0 +1,79 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/types.h>
+#include <ofono/log.h>
+#include <ofono/plugin.h>
+#include <ofono/modem.h>
+#include <ofono/gprs-provision.h>
+#include <ofono/cdma-providers.h>
+
+#include "mbpi.h"
+
+static int providers_get_name(const char *sid, char **name)
+{
+	GError *error = NULL;
+
+	DBG("Search provider name for SID %s", sid);
+
+	*name = mbpi_lookup_cdma_provider_name(sid, &error);
+	if (*name == NULL) {
+		if (error != NULL) {
+			ofono_error("%s", error->message);
+			g_error_free(error);
+		}
+
+		return -ENOENT;
+	}
+
+	DBG("Found provider name: %s", *name);
+
+	return 0;
+}
+
+static struct ofono_cdma_providers_driver providers_driver = {
+	.name = "Mobile providers",
+	.get_provider_name = providers_get_name
+};
+
+static int providers_init(void)
+{
+	return ofono_cdma_providers_driver_register(&providers_driver);
+}
+
+static void providers_exit(void)
+{
+	ofono_cdma_providers_driver_unregister(&providers_driver);
+}
+
+OFONO_PLUGIN_DEFINE(providers, "Mobile providers Plugin", VERSION,
+			OFONO_PLUGIN_PRIORITY_DEFAULT,
+			providers_init, providers_exit)
Signature · 1 line
1.7.1
#7 lore raw

PATCH 5/5 cdma-netreg: Add provider name and SID support

In reply to Philippe Nunes
---
 src/cdma-netreg.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
src/cdma-netreg.c +40 -0
index 222c3b7..a90eda9 100644
@@ -24,6 +24,7 @@
 #endif
 
 #include <errno.h>
+#include <string.h>
 
 #include <gdbus.h>
 
@@ -38,6 +39,8 @@ struct ofono_cdma_netreg {
 	const struct ofono_cdma_netreg_driver *driver;
 	void *driver_data;
 	struct ofono_atom *atom;
+	char *provider_name;
+	char *sid;
 };
 
 static const char *cdma_netreg_status_to_string(enum cdma_netreg_status status)
@@ -90,6 +93,15 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
 					&strength);
 	}
 
+	if (cdma_netreg->sid)
+		ofono_dbus_dict_append(&dict, "SystemIdentifier",
+						DBUS_TYPE_STRING,
+						&cdma_netreg->sid);
+
+	if (cdma_netreg->provider_name)
+		ofono_dbus_dict_append(&dict, "Name", DBUS_TYPE_STRING,
+						&cdma_netreg->provider_name);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -108,6 +120,8 @@ 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();
 
 	if (cdma_netreg->status != CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED
 			&& cdma_netreg->status !=
@@ -120,6 +134,30 @@ static void serving_system_callback(const struct ofono_error *error,
 	}
 
 	DBG("Serving system Identifier: %s", sid);
+
+	if (!strcmp(sid, cdma_netreg->sid))
+		return;
+
+	g_free(cdma_netreg->provider_name);
+	g_free(cdma_netreg->sid);
+	cdma_netreg->provider_name = NULL;
+	cdma_netreg->sid = g_strdup(sid);
+
+	ofono_dbus_signal_property_changed(conn, path,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
+				"SystemIdentifier", DBUS_TYPE_STRING,
+				&cdma_netreg->sid);
+
+	if (__ofono_cdma_providers_get_name(sid,
+				&cdma_netreg->provider_name) == FALSE) {
+		ofono_warn("Provider name not found");
+		return;
+	}
+
+	ofono_dbus_signal_property_changed(conn, path,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
+				"Name", DBUS_TYPE_STRING,
+				&cdma_netreg->provider_name);
 }
 
 static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
@@ -251,6 +289,8 @@ 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->sid);
+	g_free(cdma_netreg->provider_name);
 	g_free(cdma_netreg);
 }
 
Signature · 1 line
1.7.1
#2 lore raw

RE: [PATCH 1/5] cdma-providers: add driver APIs header

In reply to Philippe Nunes

Hi Philippe,

include/cdma-providers.h line 5

Quoted 10 lines
include/cdma-providers.h new file mode renamed from include/cdma-providers.h +0 -0

100644 index 0000000..8ee9e1e

include/cdma-providers.h new file +5 -0
@@ -0,0 +1,44 @@
+/*
+ *
+ *  oFono - Open Telephony stack for Linux
+ *
+ *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).

Are you sure about the copyright?

Quoted 41 lines
include/cdma-providers.h new file +40 -1
+ *
+ *  This program is free software; you can redistribute it and/or
+modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301  USA
+ *
+ */
+
+#ifndef __OFONO_CDMA_PROVIDERS_H
+#define __OFONO_CDMA_PROVIDERS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ofono_cdma_providers_driver {
+	const char *name;
+	int priority;
+	int (*get_provider_name)(const char *sid, char **name); };
+
+int ofono_cdma_providers_driver_register(
+		const struct ofono_cdma_providers_driver *driver); void
+ofono_cdma_providers_driver_unregister(
+		const struct ofono_cdma_providers_driver *driver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CDMA_PROVIDERS_H */
--
Quoted 1 line

1.7.1

Regards,

Bertrand
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#5 lore raw

RE: [PATCH 3/5] cdma-providers: add driver APIs implementation

In reply to Philippe Nunes

Hi Philippe,

src/cdma-providers.c line 5

Quoted 10 lines
src/cdma-providers.c new file +5 -0
index 0000000..d02d41c
@@ -0,0 +1,80 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).

Same comment about copyright.

Quoted 73 lines
src/cdma-providers.c new file +72 -1
+ *
+ *  This program is free software; you can redistribute it and/or
+modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <glib.h>
+#include "ofono.h"
+
+static GSList *g_drivers = NULL;
+
+ofono_bool_t __ofono_cdma_providers_get_name(const char *sid, char
+**name) {
+	GSList *d;
+
+	if (sid == NULL || strlen(sid) == 0)
+		return FALSE;
+
+	for (d = g_drivers; d != NULL; d = d->next) {
+		const struct ofono_cdma_providers_driver *driver = d->data;
+
+		if (driver->get_provider_name == NULL)
+			continue;
+
+		DBG("Calling providers plugin '%s'", driver->name);
+
+		if (driver->get_provider_name(sid, name) < 0)
+			continue;
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static gint compare_priority(gconstpointer a, gconstpointer b) {
+	const struct ofono_cdma_providers_driver *plugin1 = a;
+	const struct ofono_cdma_providers_driver *plugin2 = b;
+
+	return plugin2->priority - plugin1->priority; }
+
+int ofono_cdma_providers_driver_register(
+		const struct ofono_cdma_providers_driver *driver) {
+	DBG("driver: %p name: %s", driver, driver->name);
+
+	g_drivers = g_slist_insert_sorted(g_drivers, (void *) driver,
+						compare_priority);
+	return 0;
+}
+
+void ofono_cdma_providers_driver_unregister(
+		const struct ofono_cdma_providers_driver *driver) {
+	DBG("driver: %p name: %s", driver, driver->name);
+
+	g_drivers = g_slist_remove(g_drivers, driver); }
--
Quoted 1 line

1.7.1

Regards,

Bertrand
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.