aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mm-broadband-modem.c2
-rw-r--r--src/mm-modem-helpers.c54
-rw-r--r--src/mm-modem-helpers.h1
-rw-r--r--src/tests/test-modem-helpers.c6
4 files changed, 25 insertions, 38 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 723b2b2a..be0c9992 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -4710,7 +4710,7 @@ modem_3gpp_scan_networks_finish (MMIfaceModem3gpp *self,
if (!result)
return NULL;
- return mm_3gpp_parse_cops_test_response (result, MM_BROADBAND_MODEM (self)->priv->modem_current_charset, error);
+ return mm_3gpp_parse_cops_test_response (result, MM_BROADBAND_MODEM (self)->priv->modem_current_charset, self, error);
}
static void
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index fbbc06ef..aefe95b1 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -1243,14 +1243,15 @@ get_mm_access_tech_from_etsi_access_tech (guint act)
}
static MMModem3gppNetworkAvailability
-parse_network_status (const gchar *str)
+parse_network_status (const gchar *str,
+ gpointer log_object)
{
/* Expecting a value between '0' and '3' inclusive */
if (!str ||
strlen (str) != 1 ||
str[0] < '0' ||
str[0] > '3') {
- mm_warn ("Cannot parse network status: '%s'", str);
+ mm_obj_warn (log_object, "cannot parse network status value '%s'", str);
return MM_MODEM_3GPP_NETWORK_AVAILABILITY_UNKNOWN;
}
@@ -1258,14 +1259,15 @@ parse_network_status (const gchar *str)
}
static MMModemAccessTechnology
-parse_access_tech (const gchar *str)
+parse_access_tech (const gchar *str,
+ gpointer log_object)
{
/* Recognized access technologies are between '0' and '7' inclusive... */
if (!str ||
strlen (str) != 1 ||
str[0] < '0' ||
str[0] > '7') {
- mm_warn ("Cannot parse access tech: '%s'", str);
+ mm_obj_warn (log_object, "cannot parse access technology value '%s'", str);
return MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN;
}
@@ -1275,13 +1277,13 @@ parse_access_tech (const gchar *str)
GList *
mm_3gpp_parse_cops_test_response (const gchar *reply,
MMModemCharset cur_charset,
+ gpointer log_object,
GError **error)
{
GRegex *r;
GList *info_list = NULL;
GMatchInfo *match_info;
gboolean umts_format = TRUE;
- GError *inner_error = NULL;
g_return_val_if_fail (reply != NULL, NULL);
if (error)
@@ -1310,15 +1312,8 @@ mm_3gpp_parse_cops_test_response (const gchar *reply,
* +COPS: (2,"","T-Mobile","31026",0),(1,"AT&T","AT&T","310410"),0)
*/
- r = g_regex_new ("\\((\\d),\"([^\"\\)]*)\",([^,\\)]*),([^,\\)]*)[\\)]?,(\\d)\\)", G_REGEX_UNGREEDY, 0, &inner_error);
- if (inner_error) {
- mm_err ("Invalid regular expression: %s", inner_error->message);
- g_error_free (inner_error);
- g_set_error_literal (error,
- MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
- "Could not parse scan results");
- return NULL;
- }
+ r = g_regex_new ("\\((\\d),\"([^\"\\)]*)\",([^,\\)]*),([^,\\)]*)[\\)]?,(\\d)\\)", G_REGEX_UNGREEDY, 0, NULL);
+ g_assert (r);
/* If we didn't get any hits, try the pre-UMTS format match */
if (!g_regex_match (r, reply, 0, &match_info)) {
@@ -1339,15 +1334,8 @@ mm_3gpp_parse_cops_test_response (const gchar *reply,
* +COPS: (2,"T - Mobile",,"31026"),(1,"Einstein PCS",,"31064"),(1,"Cingular",,"31041"),,(0,1,3),(0,2)
*/
- r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^\\)]*)\\)", G_REGEX_UNGREEDY, 0, &inner_error);
- if (inner_error) {
- mm_err ("Invalid regular expression: %s", inner_error->message);
- g_error_free (inner_error);
- g_set_error_literal (error,
- MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
- "Could not parse scan results");
- return NULL;
- }
+ r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^\\)]*)\\)", G_REGEX_UNGREEDY, 0, NULL);
+ g_assert (r);
g_regex_match (r, reply, 0, &match_info);
umts_format = FALSE;
@@ -1362,7 +1350,7 @@ mm_3gpp_parse_cops_test_response (const gchar *reply,
info = g_new0 (MM3gppNetworkInfo, 1);
tmp = mm_get_string_unquoted_from_match_info (match_info, 1);
- info->status = parse_network_status (tmp);
+ info->status = parse_network_status (tmp, log_object);
g_free (tmp);
info->operator_long = mm_get_string_unquoted_from_match_info (match_info, 2);
@@ -1380,7 +1368,7 @@ mm_3gpp_parse_cops_test_response (const gchar *reply,
mm_get_string_unquoted_from_match_info (match_info, 5) :
NULL);
info->access_tech = (tmp ?
- parse_access_tech (tmp) :
+ parse_access_tech (tmp, log_object) :
MM_MODEM_ACCESS_TECHNOLOGY_GSM);
g_free (tmp);
@@ -1402,17 +1390,15 @@ mm_3gpp_parse_cops_test_response (const gchar *reply,
}
if (valid) {
- gchar *access_tech_str;
+ g_autofree gchar *access_tech_str = NULL;
access_tech_str = mm_modem_access_technology_build_string_from_mask (info->access_tech);
- mm_dbg ("Found network '%s' ('%s','%s'); availability: %s, access tech: %s",
- info->operator_code,
- info->operator_short ? info->operator_short : "no short name",
- info->operator_long ? info->operator_long : "no long name",
- mm_modem_3gpp_network_availability_get_string (info->status),
- access_tech_str);
- g_free (access_tech_str);
-
+ mm_obj_dbg (log_object, "found network '%s' ('%s','%s'); availability: %s, access tech: %s",
+ info->operator_code,
+ info->operator_short ? info->operator_short : "no short name",
+ info->operator_long ? info->operator_long : "no long name",
+ mm_modem_3gpp_network_availability_get_string (info->status),
+ access_tech_str);
info_list = g_list_prepend (info_list, info);
}
else
diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h
index 2f454104..df86bc0f 100644
--- a/src/mm-modem-helpers.h
+++ b/src/mm-modem-helpers.h
@@ -162,6 +162,7 @@ typedef struct {
void mm_3gpp_network_info_list_free (GList *info_list);
GList *mm_3gpp_parse_cops_test_response (const gchar *reply,
MMModemCharset cur_charset,
+ gpointer log_object,
GError **error);
/* AT+COPS? (current operator) response parser */
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index 1cba8148..51b28950 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -486,7 +486,7 @@ test_cops_results (const gchar *desc,
g_debug ("Testing %s +COPS response...", desc);
- results = mm_3gpp_parse_cops_test_response (reply, cur_charset, &error);
+ results = mm_3gpp_parse_cops_test_response (reply, cur_charset, NULL, &error);
g_assert (results);
g_assert_no_error (error);
g_assert_cmpuint (g_list_length (results), ==, expected_results_len);
@@ -916,7 +916,7 @@ test_cops_response_gsm_invalid (void *f, gpointer d)
GList *results;
GError *error = NULL;
- results = mm_3gpp_parse_cops_test_response (reply, MM_MODEM_CHARSET_GSM, &error);
+ results = mm_3gpp_parse_cops_test_response (reply, MM_MODEM_CHARSET_GSM, NULL, &error);
g_assert (results == NULL);
g_assert_no_error (error);
}
@@ -928,7 +928,7 @@ test_cops_response_umts_invalid (void *f, gpointer d)
GList *results;
GError *error = NULL;
- results = mm_3gpp_parse_cops_test_response (reply, MM_MODEM_CHARSET_GSM, &error);
+ results = mm_3gpp_parse_cops_test_response (reply, MM_MODEM_CHARSET_GSM, NULL, &error);
g_assert (results == NULL);
g_assert_no_error (error);
}