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)
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)
{
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;
}
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);
}
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);
}
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)
}
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;
}
}
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;
}
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);
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;