[PATCH 2/2] broadband-modem: normalize also operator code

Dan Williams dcbw at redhat.com
Sat Apr 1 04:02:00 UTC 2017


On Sat, 2017-03-25 at 21:39 +0100, Aleksander Morgado wrote:
> The operator code (MCCMNC) may also be given encoded in the current
> charset (e.g. UCS2).

LGTM.

Dan

> Based on a patch from Colin Helliwell <colin.helliwell at ln-systems.com
> >
> ---
>  plugins/altair/mm-broadband-modem-altair-lte.c | 2 +-
>  src/mm-broadband-modem.c                       | 6 ++++--
>  src/mm-modem-helpers.c                         | 4 ++--
>  src/mm-modem-helpers.h                         | 4 ++--
>  src/tests/test-modem-helpers.c                 | 7 ++++++-
>  5 files changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/plugins/altair/mm-broadband-modem-altair-lte.c
> b/plugins/altair/mm-broadband-modem-altair-lte.c
> index 1155a7a1..3cbc7ecb 100644
> --- a/plugins/altair/mm-broadband-modem-altair-lte.c
> +++ b/plugins/altair/mm-broadband-modem-altair-lte.c
> @@ -1128,7 +1128,7 @@ modem_3gpp_load_operator_name_finish
> (MMIfaceModem3gpp *self,
>                                             error))
>          return NULL;
>  
> -    mm_3gpp_normalize_operator_name (&operator_name,
> MM_MODEM_CHARSET_UNKNOWN);
> +    mm_3gpp_normalize_operator (&operator_name,
> MM_MODEM_CHARSET_UNKNOWN);
>      if (operator_name)
>          mm_dbg ("loaded Operator Name: %s", operator_name);
>      return operator_name;
> diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
> index 302fc3db..e98f8dc0 100644
> --- a/src/mm-broadband-modem.c
> +++ b/src/mm-broadband-modem.c
> @@ -3472,7 +3472,9 @@ modem_3gpp_load_operator_code_finish
> (MMIfaceModem3gpp *self,
>                                             error))
>          return NULL;
>  
> -    mm_dbg ("loaded Operator Code: %s", operator_code);
> +    mm_3gpp_normalize_operator (&operator_code, MM_BROADBAND_MODEM
> (self)->priv->modem_current_charset);
> +    if (operator_code)
> +        mm_dbg ("loaded Operator Code: %s", operator_code);
>      return operator_code;
>  }
>  
> @@ -3513,7 +3515,7 @@ modem_3gpp_load_operator_name_finish
> (MMIfaceModem3gpp *self,
>                                             error))
>          return NULL;
>  
> -    mm_3gpp_normalize_operator_name (&operator_name,
> MM_BROADBAND_MODEM (self)->priv->modem_current_charset);
> +    mm_3gpp_normalize_operator (&operator_name, MM_BROADBAND_MODEM
> (self)->priv->modem_current_charset);
>      if (operator_name)
>          mm_dbg ("loaded Operator Name: %s", operator_name);
>      return operator_name;
> diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
> index 9266a5a0..b4556176 100644
> --- a/src/mm-modem-helpers.c
> +++ b/src/mm-modem-helpers.c
> @@ -3123,8 +3123,8 @@ mm_string_to_access_tech (const gchar *string)
>  /*******************************************************************
> ******/
>  
>  void
> -mm_3gpp_normalize_operator_name (gchar          **operator,
> -                                 MMModemCharset   cur_charset)
> +mm_3gpp_normalize_operator (gchar          **operator,
> +                            MMModemCharset   cur_charset)
>  {
>      g_assert (operator);
>  
> diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h
> index 33af48b6..a74924e3 100644
> --- a/src/mm-modem-helpers.h
> +++ b/src/mm-modem-helpers.h
> @@ -294,8 +294,8 @@ gchar *mm_3gpp_facility_to_acronym
> (MMModem3gppFacility facility);
>  
>  MMModemAccessTechnology mm_string_to_access_tech (const gchar
> *string);
>  
> -void mm_3gpp_normalize_operator_name (gchar          **operator,
> -                                      MMModemCharset   cur_charset);
> +void mm_3gpp_normalize_operator (gchar          **operator,
> +                                 MMModemCharset   cur_charset);
>  
>  gboolean mm_3gpp_parse_operator_id (const gchar *operator_id,
>                                      guint16 *mcc,
> diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-
> helpers.c
> index 98f30f83..ae0eec99 100644
> --- a/src/tests/test-modem-helpers.c
> +++ b/src/tests/test-modem-helpers.c
> @@ -876,13 +876,18 @@ typedef struct {
>  static const NormalizeOperatorTest normalize_operator_tests[] = {
>      /* charset unknown */
>      { "Verizon", MM_MODEM_CHARSET_UNKNOWN, "Verizon" },
> +    { "311480",  MM_MODEM_CHARSET_UNKNOWN, "311480"  },
>      /* charset configured as IRA (ASCII) */
>      { "Verizon", MM_MODEM_CHARSET_IRA, "Verizon" },
> +    { "311480",  MM_MODEM_CHARSET_IRA, "311480"  },
>      /* charset configured as GSM7 */
>      { "Verizon", MM_MODEM_CHARSET_GSM, "Verizon" },
> +    { "311480",  MM_MODEM_CHARSET_GSM, "311480"  },
>      /* charset configured as UCS2 */
>      { "0056006500720069007A006F006E", MM_MODEM_CHARSET_UCS2,
> "Verizon" },
> +    { "003300310031003400380030",     MM_MODEM_CHARSET_UCS2,
> "311480"  },
>      { "Verizon",                      MM_MODEM_CHARSET_UCS2,
> "Verizon" },
> +    { "311480",                       MM_MODEM_CHARSET_UCS2,
> "311480"  },
>  };
>  
>  static void
> @@ -891,7 +896,7 @@ common_test_normalize_operator (const
> NormalizeOperatorTest *t)
>      gchar *str;
>  
>      str = g_strdup (t->input);
> -    mm_3gpp_normalize_operator_name (&str, t->charset);
> +    mm_3gpp_normalize_operator (&str, t->charset);
>      if (!t->normalized)
>          g_assert (!str);
>      else


More information about the ModemManager-devel mailing list