mirror of git://git.sysmocom.de/ofono
mbpi: Split gsm_start() for readability
This commit is contained in:
parent
f5d84faf22
commit
8f26272f01
|
@ -174,24 +174,14 @@ static const GMarkupParser skip_parser = {
|
|||
NULL,
|
||||
};
|
||||
|
||||
static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
|
||||
static void network_id_handler(struct gsm_data *gsm,
|
||||
const gchar **attribute_names,
|
||||
const gchar **attribute_values,
|
||||
gpointer userdata, GError **error)
|
||||
GError **error)
|
||||
{
|
||||
struct gsm_data *gsm = userdata;
|
||||
|
||||
if (g_str_equal(element_name, "network-id")) {
|
||||
const char *mcc = NULL, *mnc = NULL;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* For entries with multiple network-id elements, don't bother
|
||||
* searching if we already have a match
|
||||
*/
|
||||
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];
|
||||
|
@ -216,14 +206,19 @@ static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
|
|||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
g_markup_parse_context_push(context, &skip_parser, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -248,7 +243,28 @@ static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
|
|||
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)
|
||||
{
|
||||
if (g_str_equal(element_name, "network-id")) {
|
||||
struct gsm_data *gsm = userdata;
|
||||
|
||||
/*
|
||||
* For entries with multiple network-id elements, don't bother
|
||||
* searching if we already have a match
|
||||
*/
|
||||
if (gsm->match_found == TRUE)
|
||||
return;
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue