* [PATCHv9 00/16] Provisioning plugin
@ 2011-10-05 13:18 Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 01/16] mbpi: Remove unused includes Oleg Zhurakivskyy
` (15 more replies)
0 siblings, 16 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]
Hello,
Please find the provisioning plugin ("Internet Access Provider database" TODO item).
If enabled, the plugin reads mobile-broadband-provider-info database entries (PROVIDER_DATABASE) and returns GRPS context settings to oFono provisioning module.
Regards,
Oleg
Oleg Zhurakivskyy (16):
mbpi: Remove unused includes
mbpi: Split gsm_start() for readability
mbpi: Reflow gsm_end()
mbpi: Fix handling of the usage element
mbpi: Improve mbpi_lookup() error reporting
lookup-apn: Remove unused includes
lookup-apn: Fix crash on no APNs found
provision: Add provisioning plugin
mbpi: Add filename and line information on error
mbpi: Add mbpi_ap_type()
lookup-apn: Use mbpi_ap_type()
mbpi: Rename mbpi_provision_data_free() into mbpi_ap_free()
lookup-apn: Use mbpi_ap_free()
mbpi: Minor style issues
lookup-apn: Follow plugin's duplicates approach
lookup-apn: Minor style issues
Makefile.am | 7 ++
configure.ac | 23 +++--
plugins/mbpi.c | 291 ++++++++++++++++++++++++++++++---------------------
plugins/mbpi.h | 4 +-
plugins/provision.c | 120 +++++++++++++++++++++
tools/lookup-apn.c | 34 +++---
6 files changed, 336 insertions(+), 143 deletions(-)
create mode 100644 plugins/provision.c
--
1.7.4.1
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCHv9 01/16] mbpi: Remove unused includes
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:30 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 02/16] mbpi: Split gsm_start() for readability Oleg Zhurakivskyy
` (14 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
---
plugins/mbpi.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 683ce03..91c1ce0 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -23,12 +23,12 @@
#include <config.h>
#endif
-#include <string.h>
-#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <sys/types.h>
+
+#include <fcntl.h>
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include <glib.h>
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 02/16] mbpi: Split gsm_start() for readability
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 01/16] mbpi: Remove unused includes Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 03/16] mbpi: Reflow gsm_end() Oleg Zhurakivskyy
` (13 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4569 bytes --]
---
plugins/mbpi.c | 138 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 77 insertions(+), 61 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 91c1ce0..8cb4e23 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -174,16 +174,84 @@ static const GMarkupParser skip_parser = {
NULL,
};
+static void network_id_handler(struct gsm_data *gsm,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ GError **error)
+{
+ const char *mcc = NULL, *mnc = NULL;
+ int i;
+
+ for (i = 0; attribute_names[i]; i++) {
+ if (g_str_equal(attribute_names[i], "mcc") == TRUE)
+ mcc = attribute_values[i];
+ if (g_str_equal(attribute_names[i], "mnc") == TRUE)
+ mnc = attribute_values[i];
+ }
+
+ if (mcc == NULL) {
+ g_set_error(error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Missing attribute: mcc");
+ return;
+ }
+
+ if (mnc == NULL) {
+ g_set_error(error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Missing attribute: mnc");
+ return;
+ }
+
+ if (g_str_equal(mcc, gsm->match_mcc) &&
+ g_str_equal(mnc, gsm->match_mnc))
+ gsm->match_found = TRUE;
+}
+
+static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ GError **error)
+{
+ struct ofono_gprs_provision_data *pd;
+ const char *apn;
+ int i;
+
+ if (gsm->match_found == FALSE) {
+ g_markup_parse_context_push(context, &skip_parser, NULL);
+ return;
+ }
+
+ for (i = 0, apn = NULL; attribute_names[i]; i++) {
+ if (g_str_equal(attribute_names[i], "value") == FALSE)
+ continue;
+
+ apn = attribute_values[i];
+ break;
+ }
+
+ if (apn == NULL) {
+ g_set_error(error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "APN attribute missing");
+ return;
+ }
+
+ pd = g_new0(struct ofono_gprs_provision_data, 1);
+ pd->apn = g_strdup(apn);
+ pd->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
+ pd->proto = OFONO_GPRS_PROTO_IP;
+
+ g_markup_parse_context_push(context, &apn_parser, pd);
+}
+
static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer userdata, GError **error)
{
- struct gsm_data *gsm = userdata;
-
if (g_str_equal(element_name, "network-id")) {
- const char *mcc = NULL, *mnc = NULL;
- int i;
+ struct gsm_data *gsm = userdata;
/*
* For entries with multiple network-id elements, don't bother
@@ -192,63 +260,11 @@ static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
if (gsm->match_found == TRUE)
return;
- for (i = 0; attribute_names[i]; i++) {
- if (g_str_equal(attribute_names[i], "mcc") == TRUE)
- mcc = attribute_values[i];
- if (g_str_equal(attribute_names[i], "mnc") == TRUE)
- mnc = attribute_values[i];
- }
-
- if (mcc == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "Missing attribute: mcc");
- return;
- }
-
- if (mnc == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "Missing attribute: mnc");
- return;
- }
-
- if (g_str_equal(mcc, gsm->match_mcc) &&
- g_str_equal(mnc, gsm->match_mnc))
- gsm->match_found = TRUE;
- } else if (g_str_equal(element_name, "apn")) {
- int i;
- struct ofono_gprs_provision_data *pd;
- const char *apn;
-
- if (gsm->match_found == FALSE) {
- g_markup_parse_context_push(context,
- &skip_parser, NULL);
- return;
- }
-
- for (i = 0, apn = NULL; attribute_names[i]; i++) {
- if (g_str_equal(attribute_names[i], "value") == FALSE)
- continue;
-
- apn = attribute_values[i];
- break;
- }
-
- if (apn == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "APN attribute missing");
- return;
- }
-
- pd = g_new0(struct ofono_gprs_provision_data, 1);
- pd->apn = g_strdup(apn);
- pd->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
- pd->proto = OFONO_GPRS_PROTO_IP;
-
- g_markup_parse_context_push(context, &apn_parser, pd);
- }
+ network_id_handler(userdata, attribute_names, attribute_values,
+ error);
+ } else if (g_str_equal(element_name, "apn"))
+ apn_handler(context, userdata, attribute_names,
+ attribute_values, error);
}
static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 03/16] mbpi: Reflow gsm_end()
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 01/16] mbpi: Remove unused includes Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 02/16] mbpi: Split gsm_start() for readability Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 04/16] mbpi: Fix handling of the usage element Oleg Zhurakivskyy
` (12 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]
---
plugins/mbpi.c | 42 ++++++++++++++++++++++--------------------
1 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 8cb4e23..fce70ba 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -270,35 +270,37 @@ static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
gpointer userdata, GError **error)
{
- struct gsm_data *gsm = userdata;
+ struct gsm_data *gsm;
+ struct ofono_gprs_provision_data *apn;
+
+ if (!g_str_equal(element_name, "apn"))
+ return;
- if (g_str_equal(element_name, "apn")) {
- struct ofono_gprs_provision_data *apn =
- g_markup_parse_context_pop(context);
+ gsm = userdata;
- if (apn == NULL)
- return;
+ apn = g_markup_parse_context_pop(context);
+ if (apn == NULL)
+ return;
- if (gsm->allow_duplicates == FALSE) {
- GSList *l;
+ if (gsm->allow_duplicates == FALSE) {
+ GSList *l;
- for (l = gsm->apns; l; l = l->next) {
- struct ofono_gprs_provision_data *pd = l->data;
+ for (l = gsm->apns; l; l = l->next) {
+ struct ofono_gprs_provision_data *pd = l->data;
- if (pd->type != apn->type)
- continue;
+ if (pd->type != apn->type)
+ continue;
- g_set_error(error, mbpi_error_quark(),
- MBPI_ERROR_DUPLICATE,
- "Duplicate context detected");
+ g_set_error(error, mbpi_error_quark(),
+ MBPI_ERROR_DUPLICATE,
+ "Duplicate context detected");
- mbpi_provision_data_free(apn);
- return;
- }
+ mbpi_provision_data_free(apn);
+ return;
}
-
- gsm->apns = g_slist_append(gsm->apns, apn);
}
+
+ gsm->apns = g_slist_append(gsm->apns, apn);
}
static const GMarkupParser gsm_parser = {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 04/16] mbpi: Fix handling of the usage element
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (2 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 03/16] mbpi: Reflow gsm_end() Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting Oleg Zhurakivskyy
` (11 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2722 bytes --]
---
plugins/mbpi.c | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index fce70ba..8f3a4b4 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -90,33 +90,36 @@ static const GMarkupParser text_parser = {
NULL,
};
-static void usage_handler(GMarkupParseContext *context,
- const gchar *text, gsize text_len,
- gpointer userdata, GError **error)
+static void usage_start(const gchar **attribute_names,
+ const gchar **attribute_values,
+ enum ofono_gprs_context_type *type, GError **error)
{
- enum ofono_gprs_context_type *type = userdata;
+ const char *text = NULL;
+ int i;
+
+ for (i = 0; attribute_names[i]; i++)
+ if (g_str_equal(attribute_names[i], "type") == TRUE)
+ text = attribute_values[i];
+
+ if (text == NULL) {
+ g_set_error(error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Missing attribute: type");
+ return;
+ }
- if (strncmp(text, "internet", text_len) == 0)
+ if (strcmp(text, "internet") == 0)
*type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
- else if (strncmp(text, "mms", text_len) == 0)
+ else if (strcmp(text, "mms") == 0)
*type = OFONO_GPRS_CONTEXT_TYPE_MMS;
- else if (strncmp(text, "wap", text_len) == 0)
+ else if (strcmp(text, "wap") == 0)
*type = OFONO_GPRS_CONTEXT_TYPE_WAP;
else
g_set_error(error, G_MARKUP_ERROR,
G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
- "Unknown usage attribute: %.*s",
- (int) text_len, text);
+ "Unknown usage attribute: %s", text);
}
-static const GMarkupParser usage_parser = {
- NULL,
- NULL,
- usage_handler,
- NULL,
- NULL,
-};
-
static void apn_start(GMarkupParseContext *context, const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
@@ -133,8 +136,8 @@ static void apn_start(GMarkupParseContext *context, const gchar *element_name,
g_markup_parse_context_push(context, &text_parser,
&apn->password);
else if (g_str_equal(element_name, "usage"))
- g_markup_parse_context_push(context, &usage_parser,
- &apn->type);
+ usage_start(attribute_names, attribute_values,
+ &apn->type, error);
}
static void apn_end(GMarkupParseContext *context, const gchar *element_name,
@@ -142,8 +145,7 @@ static void apn_end(GMarkupParseContext *context, const gchar *element_name,
{
if (g_str_equal(element_name, "name") ||
g_str_equal(element_name, "username") ||
- g_str_equal(element_name, "password") ||
- g_str_equal(element_name, "usage"))
+ g_str_equal(element_name, "password"))
g_markup_parse_context_pop(context);
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (3 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 04/16] mbpi: Fix handling of the usage element Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:32 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 06/16] lookup-apn: Remove unused includes Oleg Zhurakivskyy
` (10 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]
---
plugins/mbpi.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 8f3a4b4..0f7cd50 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -378,7 +378,8 @@ GSList *mbpi_lookup(const char *mcc, const char *mnc,
if (fd < 0) {
g_set_error(error, G_FILE_ERROR,
g_file_error_from_errno(errno),
- "open failed: %s", g_strerror(errno));
+ "open(%s) failed: %s", MBPI_DATABASE,
+ g_strerror(errno));
return NULL;
}
@@ -386,7 +387,8 @@ GSList *mbpi_lookup(const char *mcc, const char *mnc,
close(fd);
g_set_error(error, G_FILE_ERROR,
g_file_error_from_errno(errno),
- "fstat failed: %s", g_strerror(errno));
+ "fstat(%s) failed: %s", MBPI_DATABASE,
+ g_strerror(errno));
return NULL;
}
@@ -395,7 +397,8 @@ GSList *mbpi_lookup(const char *mcc, const char *mnc,
close(fd);
g_set_error(error, G_FILE_ERROR,
g_file_error_from_errno(errno),
- "mmap failed: %s", g_strerror(errno));
+ "mmap(%s) failed: %s", MBPI_DATABASE,
+ g_strerror(errno));
return NULL;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 06/16] lookup-apn: Remove unused includes
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (4 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:33 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found Oleg Zhurakivskyy
` (9 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
---
tools/lookup-apn.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
index 2969baf..b192c7c 100644
--- a/tools/lookup-apn.c
+++ b/tools/lookup-apn.c
@@ -24,12 +24,7 @@
#endif
#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
#include <glib.h>
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (5 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 06/16] lookup-apn: Remove unused includes Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:35 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 08/16] provision: Add provisioning plugin Oleg Zhurakivskyy
` (8 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 604 bytes --]
---
tools/lookup-apn.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
index b192c7c..6a00293 100644
--- a/tools/lookup-apn.c
+++ b/tools/lookup-apn.c
@@ -45,7 +45,10 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
apns = mbpi_lookup(match_mcc, match_mnc, TRUE, &error);
if (apns == NULL) {
- g_print("Lookup failed: %s\n", error->message);
+ if (error != NULL) {
+ g_printerr("Lookup failed: %s\n", error->message);
+ g_error_free(error);
+ }
return;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 08/16] provision: Add provisioning plugin
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (6 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 21:56 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 09/16] mbpi: Add filename and line information on error Oleg Zhurakivskyy
` (7 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5631 bytes --]
---
Makefile.am | 7 +++
configure.ac | 23 +++++++---
plugins/provision.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 7 deletions(-)
create mode 100644 plugins/provision.c
diff --git a/Makefile.am b/Makefile.am
index 8771cb2..2704c75 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -381,6 +381,11 @@ builtin_libadd += @BLUEZ_LIBS@
endif
endif
+if PROVISION
+builtin_modules += provision
+builtin_sources += plugins/mbpi.c plugins/mbpi.h plugins/provision.c
+endif
+
if MAINTAINER_MODE
builtin_modules += example_history
builtin_sources += examples/history.c
@@ -388,8 +393,10 @@ builtin_sources += examples/history.c
builtin_modules += example_nettime
builtin_sources += examples/nettime.c
+if !PROVISION
builtin_modules += example_provision
builtin_sources += examples/provision.c
+endif
builtin_modules += example_emulator
builtin_sources += examples/emulator.c
diff --git a/configure.ac b/configure.ac
index 9e62066..36a6b73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,14 +197,23 @@ AC_SUBST(BLUEZ_CFLAGS)
AC_SUBST(BLUEZ_LIBS)
AM_CONDITIONAL(BLUETOOTH, test "${enable_bluetooth}" != "no")
-AC_MSG_CHECKING([for mobile-broadband-provider-info])
-PKG_CHECK_EXISTS(mobile-broadband-provider-info,
- _PKG_CONFIG(PROVIDER_DATABASE, [variable=database],
+AC_ARG_ENABLE(provision, AC_HELP_STRING([--enable-provision],
+ [enable GPRS context settings provisioning]),
+ [enable_provision=${enableval}])
+if (test "${enable_provision}" == "yes"); then
+ AC_MSG_CHECKING([for mobile-broadband-provider-info])
+ PKG_CHECK_EXISTS(mobile-broadband-provider-info,
+ _PKG_CONFIG(MBPI_DATABASE, [variable=database],
[mobile-broadband-provider-info])
- AC_DEFINE_UNQUOTED(PROVIDER_DATABASE, "$pkg_cv_PROVIDER_DATABASE",
- [Mobile provider database])
- AC_MSG_RESULT([yes]),
- AC_MSG_RESULT([no]))
+ AC_DEFINE_UNQUOTED(MBPI_DATABASE,
+ "$pkg_cv_MBPI_DATABASE",
+ [Provisioning database
+ (mobile-broadband-provider-info
+ package)])
+ AC_MSG_RESULT([yes]),
+ AC_MSG_ERROR(mobile-broadband-provider-info package is required))
+fi
+AM_CONDITIONAL(PROVISION, test "${enable_provision}" == "yes")
AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
[don't install configuration and data files]),
diff --git a/plugins/provision.c b/plugins/provision.c
new file mode 100644
index 0000000..3c74472
--- /dev/null
+++ b/plugins/provision.c
@@ -0,0 +1,119 @@
+/*
+ *
+ * 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 "mbpi.h"
+
+static int provision_get_settings(const char *mcc, const char *mnc,
+ const char *spn,
+ struct ofono_gprs_provision_data **settings,
+ int *count)
+{
+ GSList *l;
+ GSList *apns;
+ GError *error = NULL;
+ int ap_count;
+ int i;
+
+ DBG("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);
+
+ apns = mbpi_lookup(mcc, mnc, FALSE, &error);
+ if (apns == NULL) {
+ if (error != NULL) {
+ ofono_error("%s", error->message);
+ g_error_free(error);
+ }
+
+ return -ENOENT;
+ }
+
+ ap_count = g_slist_length(apns);
+
+ DBG("Found %d APs", ap_count);
+
+ *settings = g_try_malloc_n(ap_count,
+ sizeof(struct ofono_gprs_provision_data));
+ if (*settings == NULL) {
+ ofono_error("Provisioning failed: %s", g_strerror(errno));
+
+ for (l = apns; l; l = l->next)
+ mbpi_provision_data_free(l->data);
+
+ g_slist_free(apns);
+
+ return -ENOMEM;
+ }
+
+ *count = ap_count;
+
+ for (l = apns, i = 0; l; l = l->next, i++) {
+ struct ofono_gprs_provision_data *ap = l->data;
+
+ DBG("Name: '%s'", ap->name);
+ DBG("APN: '%s'", ap->apn);
+ DBG("Username: '%s'", ap->username);
+ DBG("Password: '%s'", ap->password);
+
+ *(*settings + i) = *ap;
+
+ memset(*settings + i, 0,
+ sizeof(struct ofono_gprs_provision_data));
+ mbpi_provision_data_free(ap);
+ }
+
+ g_slist_free(apns);
+
+ return 0;
+}
+
+static struct ofono_gprs_provision_driver provision_driver = {
+ .name = "Provisioning",
+ .get_settings = provision_get_settings
+};
+
+static int provision_init(void)
+{
+ return ofono_gprs_provision_driver_register(&provision_driver);
+}
+
+static void provision_exit(void)
+{
+ ofono_gprs_provision_driver_unregister(&provision_driver);
+}
+
+OFONO_PLUGIN_DEFINE(provision, "Provisioning Plugin", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT,
+ provision_init, provision_exit)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 09/16] mbpi: Add filename and line information on error
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (7 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 08/16] provision: Add provisioning plugin Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 22:00 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 10/16] mbpi: Add mbpi_ap_type() Oleg Zhurakivskyy
` (6 subsequent siblings)
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4669 bytes --]
---
plugins/mbpi.c | 61 ++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 0f7cd50..e4496c9 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -73,6 +73,23 @@ void mbpi_provision_data_free(struct ofono_gprs_provision_data *data)
g_free(data);
}
+static void mbpi_g_set_error(GMarkupParseContext *context, GError **error,
+ GQuark domain, gint code, const gchar *fmt, ...)
+{
+ va_list ap;
+ gint line_number, char_number;
+
+ g_markup_parse_context_get_position(context, &line_number,
+ &char_number);
+ va_start(ap, fmt);
+
+ *error = g_error_new_valist(domain, code, fmt, ap);
+
+ va_end(ap);
+
+ g_prefix_error(error, "%s:%d ", MBPI_DATABASE, line_number);
+}
+
static void text_handler(GMarkupParseContext *context,
const gchar *text, gsize text_len,
gpointer userdata, GError **error)
@@ -90,7 +107,8 @@ static const GMarkupParser text_parser = {
NULL,
};
-static void usage_start(const gchar **attribute_names,
+static void usage_start(GMarkupParseContext *context,
+ const gchar **attribute_names,
const gchar **attribute_values,
enum ofono_gprs_context_type *type, GError **error)
{
@@ -102,9 +120,9 @@ static void usage_start(const gchar **attribute_names,
text = attribute_values[i];
if (text == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "Missing attribute: type");
+ mbpi_g_set_error(context, error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Missing attribute: type");
return;
}
@@ -115,7 +133,7 @@ static void usage_start(const gchar **attribute_names,
else if (strcmp(text, "wap") == 0)
*type = OFONO_GPRS_CONTEXT_TYPE_WAP;
else
- g_set_error(error, G_MARKUP_ERROR,
+ mbpi_g_set_error(context, error, G_MARKUP_ERROR,
G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
"Unknown usage attribute: %s", text);
}
@@ -136,7 +154,7 @@ static void apn_start(GMarkupParseContext *context, const gchar *element_name,
g_markup_parse_context_push(context, &text_parser,
&apn->password);
else if (g_str_equal(element_name, "usage"))
- usage_start(attribute_names, attribute_values,
+ usage_start(context, attribute_names, attribute_values,
&apn->type, error);
}
@@ -176,7 +194,8 @@ static const GMarkupParser skip_parser = {
NULL,
};
-static void network_id_handler(struct gsm_data *gsm,
+static void network_id_handler(GMarkupParseContext *context,
+ struct gsm_data *gsm,
const gchar **attribute_names,
const gchar **attribute_values,
GError **error)
@@ -192,16 +211,16 @@ static void network_id_handler(struct gsm_data *gsm,
}
if (mcc == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "Missing attribute: mcc");
+ mbpi_g_set_error(context, error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Missing attribute: mcc");
return;
}
if (mnc == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "Missing attribute: mnc");
+ mbpi_g_set_error(context, error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Missing attribute: mnc");
return;
}
@@ -233,9 +252,9 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
}
if (apn == NULL) {
- g_set_error(error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "APN attribute missing");
+ mbpi_g_set_error(context, error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "APN attribute missing");
return;
}
@@ -262,8 +281,8 @@ static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
if (gsm->match_found == TRUE)
return;
- network_id_handler(userdata, attribute_names, attribute_values,
- error);
+ network_id_handler(context, userdata, attribute_names,
+ attribute_values, error);
} else if (g_str_equal(element_name, "apn"))
apn_handler(context, userdata, attribute_names,
attribute_values, error);
@@ -293,9 +312,9 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
if (pd->type != apn->type)
continue;
- g_set_error(error, mbpi_error_quark(),
- MBPI_ERROR_DUPLICATE,
- "Duplicate context detected");
+ mbpi_g_set_error(context, error, mbpi_error_quark(),
+ MBPI_ERROR_DUPLICATE,
+ "Duplicate context detected");
mbpi_provision_data_free(apn);
return;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 10/16] mbpi: Add mbpi_ap_type()
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (8 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 09/16] mbpi: Add filename and line information on error Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 11/16] lookup-apn: Use mbpi_ap_type() Oleg Zhurakivskyy
` (5 subsequent siblings)
15 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]
---
plugins/mbpi.c | 15 +++++++++++++++
plugins/mbpi.h | 2 ++
plugins/provision.c | 1 +
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index e4496c9..3ab60c4 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -44,6 +44,8 @@
#include "mbpi.h"
+#define _(x) case x: return (#x)
+
enum MBPI_ERROR {
MBPI_ERROR_DUPLICATE,
};
@@ -56,6 +58,19 @@ struct gsm_data {
gboolean allow_duplicates;
};
+const char *mbpi_ap_type(enum ofono_gprs_context_type type)
+{
+ switch (type) {
+ _(OFONO_GPRS_CONTEXT_TYPE_ANY);
+ _(OFONO_GPRS_CONTEXT_TYPE_INTERNET);
+ _(OFONO_GPRS_CONTEXT_TYPE_MMS);
+ _(OFONO_GPRS_CONTEXT_TYPE_WAP);
+ _(OFONO_GPRS_CONTEXT_TYPE_IMS);
+ }
+
+ return "OFONO_GPRS_CONTEXT_TYPE_<UNKNOWN>";
+}
+
static GQuark mbpi_error_quark(void)
{
return g_quark_from_static_string("ofono-mbpi-error-quark");
diff --git a/plugins/mbpi.h b/plugins/mbpi.h
index fc9f738..5a844d1 100644
--- a/plugins/mbpi.h
+++ b/plugins/mbpi.h
@@ -19,6 +19,8 @@
*
*/
+const char *mbpi_ap_type(enum ofono_gprs_context_type type);
+
void mbpi_provision_data_free(struct ofono_gprs_provision_data *data);
GSList *mbpi_lookup(const char *mcc, const char *mnc,
diff --git a/plugins/provision.c b/plugins/provision.c
index 3c74472..c099891 100644
--- a/plugins/provision.c
+++ b/plugins/provision.c
@@ -84,6 +84,7 @@ static int provision_get_settings(const char *mcc, const char *mnc,
DBG("Name: '%s'", ap->name);
DBG("APN: '%s'", ap->apn);
+ DBG("Type: %s", mbpi_ap_type(ap->type));
DBG("Username: '%s'", ap->username);
DBG("Password: '%s'", ap->password);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 11/16] lookup-apn: Use mbpi_ap_type()
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (9 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 10/16] mbpi: Add mbpi_ap_type() Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 12/16] mbpi: Rename mbpi_provision_data_free() into mbpi_ap_free() Oleg Zhurakivskyy
` (4 subsequent siblings)
15 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 563 bytes --]
---
tools/lookup-apn.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
index 6a00293..90ef3a4 100644
--- a/tools/lookup-apn.c
+++ b/tools/lookup-apn.c
@@ -58,6 +58,7 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
printf("\n");
printf("Name: %s\n", apn->name);
printf("APN: %s\n", apn->apn);
+ printf("Type: %s\n", mbpi_ap_type(apn->type));
printf("Username: %s\n", apn->username);
printf("Password: %s\n", apn->password);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 12/16] mbpi: Rename mbpi_provision_data_free() into mbpi_ap_free()
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (10 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 11/16] lookup-apn: Use mbpi_ap_type() Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 13/16] lookup-apn: Use mbpi_ap_free() Oleg Zhurakivskyy
` (3 subsequent siblings)
15 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2586 bytes --]
---
plugins/mbpi.c | 8 ++++----
plugins/mbpi.h | 2 +-
plugins/provision.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 3ab60c4..7101629 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -76,7 +76,7 @@ static GQuark mbpi_error_quark(void)
return g_quark_from_static_string("ofono-mbpi-error-quark");
}
-void mbpi_provision_data_free(struct ofono_gprs_provision_data *data)
+void mbpi_ap_free(struct ofono_gprs_provision_data *data)
{
g_free(data->name);
g_free(data->apn);
@@ -190,7 +190,7 @@ static void apn_error(GMarkupParseContext *context, GError *error,
* be called. So we always perform cleanup of the allocated
* provision data
*/
- mbpi_provision_data_free(userdata);
+ mbpi_ap_free(userdata);
}
static const GMarkupParser apn_parser = {
@@ -331,7 +331,7 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
MBPI_ERROR_DUPLICATE,
"Duplicate context detected");
- mbpi_provision_data_free(apn);
+ mbpi_ap_free(apn);
return;
}
}
@@ -443,7 +443,7 @@ GSList *mbpi_lookup(const char *mcc, const char *mnc,
if (mbpi_parse(db, st.st_size, &gsm, error) == FALSE) {
for (l = gsm.apns; l; l = l->next)
- mbpi_provision_data_free(l->data);
+ mbpi_ap_free(l->data);
g_slist_free(gsm.apns);
gsm.apns = NULL;
diff --git a/plugins/mbpi.h b/plugins/mbpi.h
index 5a844d1..42e439b 100644
--- a/plugins/mbpi.h
+++ b/plugins/mbpi.h
@@ -21,7 +21,7 @@
const char *mbpi_ap_type(enum ofono_gprs_context_type type);
-void mbpi_provision_data_free(struct ofono_gprs_provision_data *data);
+void mbpi_ap_free(struct ofono_gprs_provision_data *data);
GSList *mbpi_lookup(const char *mcc, const char *mnc,
gboolean allow_duplicates, GError **error);
diff --git a/plugins/provision.c b/plugins/provision.c
index c099891..c89a013 100644
--- a/plugins/provision.c
+++ b/plugins/provision.c
@@ -70,7 +70,7 @@ static int provision_get_settings(const char *mcc, const char *mnc,
ofono_error("Provisioning failed: %s", g_strerror(errno));
for (l = apns; l; l = l->next)
- mbpi_provision_data_free(l->data);
+ mbpi_ap_free(l->data);
g_slist_free(apns);
@@ -92,7 +92,7 @@ static int provision_get_settings(const char *mcc, const char *mnc,
memset(*settings + i, 0,
sizeof(struct ofono_gprs_provision_data));
- mbpi_provision_data_free(ap);
+ mbpi_ap_free(ap);
}
g_slist_free(apns);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 13/16] lookup-apn: Use mbpi_ap_free()
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (11 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 12/16] mbpi: Rename mbpi_provision_data_free() into mbpi_ap_free() Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 14/16] mbpi: Minor style issues Oleg Zhurakivskyy
` (2 subsequent siblings)
15 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 512 bytes --]
---
tools/lookup-apn.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
index 90ef3a4..3918f18 100644
--- a/tools/lookup-apn.c
+++ b/tools/lookup-apn.c
@@ -62,7 +62,7 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
printf("Username: %s\n", apn->username);
printf("Password: %s\n", apn->password);
- mbpi_provision_data_free(apn);
+ mbpi_ap_free(apn);
}
g_slist_free(apns);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 14/16] mbpi: Minor style issues
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (12 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 13/16] lookup-apn: Use mbpi_ap_free() Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 16/16] lookup-apn: Minor style issues Oleg Zhurakivskyy
15 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3031 bytes --]
---
plugins/mbpi.c | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index 7101629..63492da 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -76,16 +76,16 @@ static GQuark mbpi_error_quark(void)
return g_quark_from_static_string("ofono-mbpi-error-quark");
}
-void mbpi_ap_free(struct ofono_gprs_provision_data *data)
+void mbpi_ap_free(struct ofono_gprs_provision_data *ap)
{
- g_free(data->name);
- g_free(data->apn);
- g_free(data->username);
- g_free(data->password);
- g_free(data->message_proxy);
- g_free(data->message_center);
-
- g_free(data);
+ g_free(ap->name);
+ g_free(ap->apn);
+ g_free(ap->username);
+ g_free(ap->password);
+ g_free(ap->message_proxy);
+ g_free(ap->message_center);
+
+ g_free(ap);
}
static void mbpi_g_set_error(GMarkupParseContext *context, GError **error,
@@ -249,7 +249,7 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
const gchar **attribute_values,
GError **error)
{
- struct ofono_gprs_provision_data *pd;
+ struct ofono_gprs_provision_data *ap;
const char *apn;
int i;
@@ -273,12 +273,12 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
return;
}
- pd = g_new0(struct ofono_gprs_provision_data, 1);
- pd->apn = g_strdup(apn);
- pd->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
- pd->proto = OFONO_GPRS_PROTO_IP;
+ ap = g_new0(struct ofono_gprs_provision_data, 1);
+ ap->apn = g_strdup(apn);
+ ap->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
+ ap->proto = OFONO_GPRS_PROTO_IP;
- g_markup_parse_context_push(context, &apn_parser, pd);
+ g_markup_parse_context_push(context, &apn_parser, ap);
}
static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
@@ -307,15 +307,15 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
gpointer userdata, GError **error)
{
struct gsm_data *gsm;
- struct ofono_gprs_provision_data *apn;
+ struct ofono_gprs_provision_data *ap;
if (!g_str_equal(element_name, "apn"))
return;
gsm = userdata;
- apn = g_markup_parse_context_pop(context);
- if (apn == NULL)
+ ap = g_markup_parse_context_pop(context);
+ if (ap == NULL)
return;
if (gsm->allow_duplicates == FALSE) {
@@ -324,19 +324,19 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
for (l = gsm->apns; l; l = l->next) {
struct ofono_gprs_provision_data *pd = l->data;
- if (pd->type != apn->type)
+ if (pd->type != ap->type)
continue;
mbpi_g_set_error(context, error, mbpi_error_quark(),
MBPI_ERROR_DUPLICATE,
"Duplicate context detected");
- mbpi_ap_free(apn);
+ mbpi_ap_free(ap);
return;
}
}
- gsm->apns = g_slist_append(gsm->apns, apn);
+ gsm->apns = g_slist_append(gsm->apns, ap);
}
static const GMarkupParser gsm_parser = {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (13 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 14/16] mbpi: Minor style issues Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
2011-10-12 22:01 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 16/16] lookup-apn: Minor style issues Oleg Zhurakivskyy
15 siblings, 1 reply; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 581 bytes --]
---
tools/lookup-apn.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
index 3918f18..9c0d345 100644
--- a/tools/lookup-apn.c
+++ b/tools/lookup-apn.c
@@ -42,7 +42,7 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
printf("Searching for info for network: %s%s\n", match_mcc, match_mnc);
- apns = mbpi_lookup(match_mcc, match_mnc, TRUE, &error);
+ apns = mbpi_lookup(match_mcc, match_mnc, FALSE, &error);
if (apns == NULL) {
if (error != NULL) {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCHv9 16/16] lookup-apn: Minor style issues
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
` (14 preceding siblings ...)
2011-10-05 13:18 ` [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach Oleg Zhurakivskyy
@ 2011-10-05 13:18 ` Oleg Zhurakivskyy
15 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-05 13:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1847 bytes --]
---
tools/lookup-apn.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
index 9c0d345..29c0027 100644
--- a/tools/lookup-apn.c
+++ b/tools/lookup-apn.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
@@ -40,7 +39,7 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
GSList *apns;
GError *error = NULL;
- printf("Searching for info for network: %s%s\n", match_mcc, match_mnc);
+ g_print("Searching for info for network: %s%s\n", match_mcc, match_mnc);
apns = mbpi_lookup(match_mcc, match_mnc, FALSE, &error);
@@ -53,16 +52,16 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
}
for (l = apns; l; l = l->next) {
- struct ofono_gprs_provision_data *apn = l->data;
+ struct ofono_gprs_provision_data *ap = l->data;
- printf("\n");
- printf("Name: %s\n", apn->name);
- printf("APN: %s\n", apn->apn);
- printf("Type: %s\n", mbpi_ap_type(apn->type));
- printf("Username: %s\n", apn->username);
- printf("Password: %s\n", apn->password);
+ g_print("\n");
+ g_print("Name: %s\n", ap->name);
+ g_print("APN: %s\n", ap->apn);
+ g_print("Type: %s\n", mbpi_ap_type(ap->type));
+ g_print("Username: %s\n", ap->username);
+ g_print("Password: %s\n", ap->password);
- mbpi_ap_free(apn);
+ mbpi_ap_free(ap);
}
g_slist_free(apns);
@@ -96,12 +95,12 @@ int main(int argc, char **argv)
g_option_context_free(context);
if (option_version == TRUE) {
- printf("%s\n", VERSION);
+ g_print("%s\n", VERSION);
exit(0);
}
if (argc < 2) {
- fprintf(stderr, "Missing parameters\n");
+ g_printerr("Missing parameters\n");
exit(1);
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCHv9 01/16] mbpi: Remove unused includes
2011-10-05 13:18 ` [PATCHv9 01/16] mbpi: Remove unused includes Oleg Zhurakivskyy
@ 2011-10-12 21:30 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:30 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 736 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> plugins/mbpi.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/plugins/mbpi.c b/plugins/mbpi.c
> index 683ce03..91c1ce0 100644
> --- a/plugins/mbpi.c
> +++ b/plugins/mbpi.c
> @@ -23,12 +23,12 @@
> #include <config.h>
> #endif
>
> -#include <string.h>
> -#include <fcntl.h>
> #include <sys/mman.h>
> #include <sys/stat.h>
> -#include <sys/types.h>
Unfortunately sys/types.h is required for the open system call. Please
refer to 'man 2 open' for details.
> +
> +#include <fcntl.h>
> #include <errno.h>
> +#include <string.h>
> #include <unistd.h>
>
> #include <glib.h>
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 02/16] mbpi: Split gsm_start() for readability
2011-10-05 13:18 ` [PATCHv9 02/16] mbpi: Split gsm_start() for readability Oleg Zhurakivskyy
@ 2011-10-12 21:31 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:31 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 266 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> plugins/mbpi.c | 138 +++++++++++++++++++++++++++++++-------------------------
> 1 files changed, 77 insertions(+), 61 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 03/16] mbpi: Reflow gsm_end()
2011-10-05 13:18 ` [PATCHv9 03/16] mbpi: Reflow gsm_end() Oleg Zhurakivskyy
@ 2011-10-12 21:31 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:31 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 252 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> plugins/mbpi.c | 42 ++++++++++++++++++++++--------------------
> 1 files changed, 22 insertions(+), 20 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 04/16] mbpi: Fix handling of the usage element
2011-10-05 13:18 ` [PATCHv9 04/16] mbpi: Fix handling of the usage element Oleg Zhurakivskyy
@ 2011-10-12 21:31 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:31 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> plugins/mbpi.c | 44 +++++++++++++++++++++++---------------------
> 1 files changed, 23 insertions(+), 21 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting
2011-10-05 13:18 ` [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting Oleg Zhurakivskyy
@ 2011-10-12 21:32 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:32 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> plugins/mbpi.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 06/16] lookup-apn: Remove unused includes
2011-10-05 13:18 ` [PATCHv9 06/16] lookup-apn: Remove unused includes Oleg Zhurakivskyy
@ 2011-10-12 21:33 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 213 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> tools/lookup-apn.c | 5 -----
> 1 files changed, 0 insertions(+), 5 deletions(-)
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found
2011-10-05 13:18 ` [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found Oleg Zhurakivskyy
@ 2011-10-12 21:35 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:35 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> tools/lookup-apn.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 08/16] provision: Add provisioning plugin
2011-10-05 13:18 ` [PATCHv9 08/16] provision: Add provisioning plugin Oleg Zhurakivskyy
@ 2011-10-12 21:56 ` Denis Kenzior
2011-10-13 11:29 ` Oleg Zhurakivskyy
0 siblings, 1 reply; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 21:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2471 bytes --]
Hi Oleg,
<snip>
> +static int provision_get_settings(const char *mcc, const char *mnc,
> + const char *spn,
> + struct ofono_gprs_provision_data **settings,
> + int *count)
> +{
> + GSList *l;
> + GSList *apns;
> + GError *error = NULL;
> + int ap_count;
> + int i;
> +
> + DBG("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);
> +
> + apns = mbpi_lookup(mcc, mnc, FALSE, &error);
> + if (apns == NULL) {
> + if (error != NULL) {
> + ofono_error("%s", error->message);
> + g_error_free(error);
> + }
> +
> + return -ENOENT;
> + }
> +
> + ap_count = g_slist_length(apns);
> +
> + DBG("Found %d APs", ap_count);
> +
> + *settings = g_try_malloc_n(ap_count,
> + sizeof(struct ofono_gprs_provision_data));
Please use g_try_new0 instead of g_try_malloc_n. The result will be a
bit prettier.
> + if (*settings == NULL) {
> + ofono_error("Provisioning failed: %s", g_strerror(errno));
> +
> + for (l = apns; l; l = l->next)
> + mbpi_provision_data_free(l->data);
> +
> + g_slist_free(apns);
> +
> + return -ENOMEM;
> + }
> +
> + *count = ap_count;
> +
> + for (l = apns, i = 0; l; l = l->next, i++) {
> + struct ofono_gprs_provision_data *ap = l->data;
> +
> + DBG("Name: '%s'", ap->name);
> + DBG("APN: '%s'", ap->apn);
> + DBG("Username: '%s'", ap->username);
> + DBG("Password: '%s'", ap->password);
> +
> + *(*settings + i) = *ap;
Please don't use this particular syntax, we prefer using memcpy for this.
> +
> + memset(*settings + i, 0,
> + sizeof(struct ofono_gprs_provision_data));
Do you mean to memset the contents of ap here? The way I read this code
you're setting an entry in the return array and immediately resetting it
to 0.
> + mbpi_provision_data_free(ap);
using g_free(ap) might be the easier solution.
> + }
> +
> + g_slist_free(apns);
> +
> + return 0;
> +}
> +
> +static struct ofono_gprs_provision_driver provision_driver = {
> + .name = "Provisioning",
> + .get_settings = provision_get_settings
> +};
> +
> +static int provision_init(void)
> +{
> + return ofono_gprs_provision_driver_register(&provision_driver);
> +}
> +
> +static void provision_exit(void)
> +{
> + ofono_gprs_provision_driver_unregister(&provision_driver);
> +}
> +
> +OFONO_PLUGIN_DEFINE(provision, "Provisioning Plugin", VERSION,
> + OFONO_PLUGIN_PRIORITY_DEFAULT,
> + provision_init, provision_exit)
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 09/16] mbpi: Add filename and line information on error
2011-10-05 13:18 ` [PATCHv9 09/16] mbpi: Add filename and line information on error Oleg Zhurakivskyy
@ 2011-10-12 22:00 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 22:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> plugins/mbpi.c | 61 ++++++++++++++++++++++++++++++++++++-------------------
> 1 files changed, 40 insertions(+), 21 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach
2011-10-05 13:18 ` [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach Oleg Zhurakivskyy
@ 2011-10-12 22:01 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2011-10-12 22:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 759 bytes --]
Hi Oleg,
On 10/05/2011 08:18 AM, Oleg Zhurakivskyy wrote:
> ---
> tools/lookup-apn.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tools/lookup-apn.c b/tools/lookup-apn.c
> index 3918f18..9c0d345 100644
> --- a/tools/lookup-apn.c
> +++ b/tools/lookup-apn.c
> @@ -42,7 +42,7 @@ static void lookup_apn(const char *match_mcc, const char *match_mnc)
>
> printf("Searching for info for network: %s%s\n", match_mcc, match_mnc);
>
> - apns = mbpi_lookup(match_mcc, match_mnc, TRUE, &error);
> + apns = mbpi_lookup(match_mcc, match_mnc, FALSE, &error);
Can we make this a command line option instead and default to TRUE here?
>
> if (apns == NULL) {
> if (error != NULL) {
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCHv9 08/16] provision: Add provisioning plugin
2011-10-12 21:56 ` Denis Kenzior
@ 2011-10-13 11:29 ` Oleg Zhurakivskyy
0 siblings, 0 replies; 28+ messages in thread
From: Oleg Zhurakivskyy @ 2011-10-13 11:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
Hello Denis,
On 10/13/2011 12:56 AM, Denis Kenzior wrote:
> Please use g_try_new0 instead of g_try_malloc_n. The result will be a
> bit prettier.
OK.
> Please don't use this particular syntax, we prefer using memcpy for this.
OK.
>> + memset(*settings + i, 0,
>> + sizeof(struct ofono_gprs_provision_data));
>
> Do you mean to memset the contents of ap here?
Yes. Sorry, this has slipped from one of the previous versions, I will correct.
>> + mbpi_provision_data_free(ap);
>
> using g_free(ap) might be the easier solution.
Sure, indeed.
Thanks for the review, I will correct and send another patch.
Regards,
Oleg
--
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2011-10-13 11:29 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 01/16] mbpi: Remove unused includes Oleg Zhurakivskyy
2011-10-12 21:30 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 02/16] mbpi: Split gsm_start() for readability Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 03/16] mbpi: Reflow gsm_end() Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 04/16] mbpi: Fix handling of the usage element Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting Oleg Zhurakivskyy
2011-10-12 21:32 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 06/16] lookup-apn: Remove unused includes Oleg Zhurakivskyy
2011-10-12 21:33 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found Oleg Zhurakivskyy
2011-10-12 21:35 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 08/16] provision: Add provisioning plugin Oleg Zhurakivskyy
2011-10-12 21:56 ` Denis Kenzior
2011-10-13 11:29 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 09/16] mbpi: Add filename and line information on error Oleg Zhurakivskyy
2011-10-12 22:00 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 10/16] mbpi: Add mbpi_ap_type() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 11/16] lookup-apn: Use mbpi_ap_type() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 12/16] mbpi: Rename mbpi_provision_data_free() into mbpi_ap_free() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 13/16] lookup-apn: Use mbpi_ap_free() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 14/16] mbpi: Minor style issues Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach Oleg Zhurakivskyy
2011-10-12 22:01 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 16/16] lookup-apn: Minor style issues Oleg Zhurakivskyy
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.