libmm-glib,iface-modem-location: add MMLocation3gpp 3 digit MNC support
MMLocation3gpp provides MCC/MNC information as integers, so it can not make distinction between operator codes such as XXX01 and XXX001. This commit deprecates mm_location_3gpp_get_mobile_network_code() and implements a new function mm_location_3gpp_get_operator_code() which provides the MCC+MNC in string format. The mm_location_3gpp_get_mobile_country_code() is still available as returning the MCC as an integer does not have ambiguity issues.
This commit is contained in:
@@ -1424,15 +1424,13 @@ load_operator_code_ready (MMIfaceModem3gpp *self,
|
||||
ReloadCurrentRegistrationInfoContext *ctx;
|
||||
GError *error = NULL;
|
||||
gchar *str;
|
||||
guint16 mcc = 0;
|
||||
guint16 mnc = 0;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
str = MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_operator_code_finish (self, res, &error);
|
||||
if (error) {
|
||||
mm_obj_warn (self, "couldn't load operator code: %s", error->message);
|
||||
} else if (!mm_3gpp_parse_operator_id (str, &mcc, &mnc, NULL, &error)) {
|
||||
} else if (!mm_3gpp_parse_operator_id (str, NULL, NULL, NULL, &error)) {
|
||||
mm_obj_dbg (self, "unexpected operator code string '%s': %s", str, error->message);
|
||||
g_clear_pointer (&str, g_free);
|
||||
}
|
||||
@@ -1442,8 +1440,8 @@ load_operator_code_ready (MMIfaceModem3gpp *self,
|
||||
mm_gdbus_modem3gpp_set_operator_code (ctx->skeleton, str);
|
||||
|
||||
/* If we also implement the location interface, update the 3GPP location */
|
||||
if (mcc && MM_IS_IFACE_MODEM_LOCATION (self))
|
||||
mm_iface_modem_location_3gpp_update_mcc_mnc (MM_IFACE_MODEM_LOCATION (self), mcc, mnc);
|
||||
if (str && MM_IS_IFACE_MODEM_LOCATION (self))
|
||||
mm_iface_modem_location_3gpp_update_operator_code (MM_IFACE_MODEM_LOCATION (self), str);
|
||||
|
||||
g_free (str);
|
||||
|
||||
@@ -1513,7 +1511,7 @@ mm_iface_modem_3gpp_reload_current_registration_info (MMIfaceModem3gpp *self,
|
||||
if (ctx->operator_code_loaded) {
|
||||
mm_gdbus_modem3gpp_set_operator_code (ctx->skeleton, NULL);
|
||||
if (MM_IS_IFACE_MODEM_LOCATION (self))
|
||||
mm_iface_modem_location_3gpp_update_mcc_mnc (MM_IFACE_MODEM_LOCATION (self), 0, 0);
|
||||
mm_iface_modem_location_3gpp_update_operator_code (MM_IFACE_MODEM_LOCATION (self), NULL);
|
||||
}
|
||||
|
||||
ctx->operator_name_loaded = !(MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_operator_name &&
|
||||
@@ -1538,7 +1536,7 @@ mm_iface_modem_3gpp_clear_current_operator (MMIfaceModem3gpp *self)
|
||||
mm_gdbus_modem3gpp_set_operator_code (skeleton, NULL);
|
||||
mm_gdbus_modem3gpp_set_operator_name (skeleton, NULL);
|
||||
if (MM_IS_IFACE_MODEM_LOCATION (self))
|
||||
mm_iface_modem_location_3gpp_update_mcc_mnc (MM_IFACE_MODEM_LOCATION (self), 0, 0);
|
||||
mm_iface_modem_location_3gpp_update_operator_code (MM_IFACE_MODEM_LOCATION (self), NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -345,10 +345,12 @@ notify_3gpp_location_update (MMIfaceModemLocation *self,
|
||||
MmGdbusModemLocation *skeleton,
|
||||
MMLocation3gpp *location_3gpp)
|
||||
{
|
||||
const gchar *operator_code;
|
||||
|
||||
operator_code = mm_location_3gpp_get_operator_code (location_3gpp);
|
||||
mm_obj_dbg (self, "3GPP location updated "
|
||||
"(MCC: '%u', MNC: '%u', location area code: '%lX', tracking area code: '%lX', cell ID: '%lX')",
|
||||
mm_location_3gpp_get_mobile_country_code (location_3gpp),
|
||||
mm_location_3gpp_get_mobile_network_code (location_3gpp),
|
||||
"(MCCMNC: '%s', location area code: '%lX', tracking area code: '%lX', cell ID: '%lX')",
|
||||
operator_code ? operator_code : "<none>",
|
||||
mm_location_3gpp_get_location_area_code (location_3gpp),
|
||||
mm_location_3gpp_get_tracking_area_code (location_3gpp),
|
||||
mm_location_3gpp_get_cell_id (location_3gpp));
|
||||
@@ -365,9 +367,8 @@ notify_3gpp_location_update (MMIfaceModemLocation *self,
|
||||
}
|
||||
|
||||
void
|
||||
mm_iface_modem_location_3gpp_update_mcc_mnc (MMIfaceModemLocation *self,
|
||||
guint mobile_country_code,
|
||||
guint mobile_network_code)
|
||||
mm_iface_modem_location_3gpp_update_operator_code (MMIfaceModemLocation *self,
|
||||
const gchar *operator_code)
|
||||
{
|
||||
MmGdbusModemLocation *skeleton;
|
||||
LocationContext *ctx;
|
||||
@@ -383,10 +384,8 @@ mm_iface_modem_location_3gpp_update_mcc_mnc (MMIfaceModemLocation *self,
|
||||
guint changed = 0;
|
||||
|
||||
g_assert (ctx->location_3gpp != NULL);
|
||||
changed += mm_location_3gpp_set_mobile_country_code (ctx->location_3gpp,
|
||||
mobile_country_code);
|
||||
changed += mm_location_3gpp_set_mobile_network_code (ctx->location_3gpp,
|
||||
mobile_network_code);
|
||||
changed += mm_location_3gpp_set_operator_code (ctx->location_3gpp,
|
||||
operator_code);
|
||||
if (changed)
|
||||
notify_3gpp_location_update (self, skeleton, ctx->location_3gpp);
|
||||
}
|
||||
|
||||
@@ -139,9 +139,8 @@ void mm_iface_modem_location_shutdown (MMIfaceModemLocation *self);
|
||||
|
||||
/* Update 3GPP (LAC/CI) location */
|
||||
void mm_iface_modem_location_3gpp_clear (MMIfaceModemLocation *self);
|
||||
void mm_iface_modem_location_3gpp_update_mcc_mnc (MMIfaceModemLocation *self,
|
||||
guint mobile_country_code,
|
||||
guint mobile_network_code);
|
||||
void mm_iface_modem_location_3gpp_update_operator_code (MMIfaceModemLocation *self,
|
||||
const gchar *operator_code);
|
||||
void mm_iface_modem_location_3gpp_update_lac_tac_ci (MMIfaceModemLocation *self,
|
||||
gulong location_area_code,
|
||||
gulong tracking_area_code,
|
||||
|
||||
Reference in New Issue
Block a user