iface-modem-3gpp: helpers to check if specific domains are supported

This commit is contained in:
Aleksander Morgado
2022-09-16 10:31:35 +00:00
committed by Aleksander Morgado
parent 1fa67b3842
commit 7b0b3e7e48

View File

@@ -106,6 +106,25 @@ get_private (MMIfaceModem3gpp *self)
return priv;
}
/*****************************************************************************/
#define GET_NETWORK_SUPPORTED(domain,DOMAIN) \
static gboolean \
get_##domain##_network_supported (MMIfaceModem3gpp *self) \
{ \
gboolean supported = FALSE; \
\
g_object_get (self, \
MM_IFACE_MODEM_3GPP_##DOMAIN##_NETWORK_SUPPORTED, &supported, \
NULL); \
return supported; \
}
GET_NETWORK_SUPPORTED (cs, CS)
GET_NETWORK_SUPPORTED (ps, PS)
GET_NETWORK_SUPPORTED (eps, EPS)
GET_NETWORK_SUPPORTED (5gs, 5GS)
/*****************************************************************************/
/* Helper method to wait for a final packet service state */
@@ -1747,19 +1766,17 @@ mm_iface_modem_3gpp_run_registration_checks (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
gboolean is_cs_supported = FALSE;
gboolean is_ps_supported = FALSE;
gboolean is_eps_supported = FALSE;
gboolean is_5gs_supported = FALSE;
gboolean is_cs_supported;
gboolean is_ps_supported;
gboolean is_eps_supported;
gboolean is_5gs_supported;
g_assert (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->run_registration_checks != NULL);
g_object_get (self,
MM_IFACE_MODEM_3GPP_CS_NETWORK_SUPPORTED, &is_cs_supported,
MM_IFACE_MODEM_3GPP_PS_NETWORK_SUPPORTED, &is_ps_supported,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &is_eps_supported,
MM_IFACE_MODEM_3GPP_5GS_NETWORK_SUPPORTED, &is_5gs_supported,
NULL);
is_cs_supported = get_cs_network_supported (self);
is_ps_supported = get_ps_network_supported (self);
is_eps_supported = get_eps_network_supported (self);
is_5gs_supported = get_5gs_network_supported (self);
mm_obj_dbg (self, "running registration checks (CS: '%s', PS: '%s', EPS: '%s', 5GS: '%s')",
is_cs_supported ? "yes" : "no",
@@ -2139,93 +2156,28 @@ update_registration_state (MMIfaceModem3gpp *self,
update_non_registered_state (self, old_state, new_state);
}
void
mm_iface_modem_3gpp_update_cs_registration_state (MMIfaceModem3gpp *self,
MMModem3gppRegistrationState state,
gboolean deferred)
{
Private *priv;
gboolean supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_CS_NETWORK_SUPPORTED, &supported,
NULL);
if (!supported)
return;
priv = get_private (self);
priv->state_cs = state;
if (!deferred)
mm_iface_modem_3gpp_apply_deferred_registration_state (self);
#define UPDATE_REGISTRATION_STATE(domain) \
void \
mm_iface_modem_3gpp_update_##domain##_registration_state (MMIfaceModem3gpp *self, \
MMModem3gppRegistrationState state, \
gboolean deferred) \
{ \
Private *priv; \
\
if (!get_##domain##_network_supported (self)) \
return; \
\
priv = get_private (self); \
priv->state_##domain = state; \
\
if (!deferred) \
mm_iface_modem_3gpp_apply_deferred_registration_state (self); \
}
void
mm_iface_modem_3gpp_update_ps_registration_state (MMIfaceModem3gpp *self,
MMModem3gppRegistrationState state,
gboolean deferred)
{
Private *priv;
gboolean supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_PS_NETWORK_SUPPORTED, &supported,
NULL);
if (!supported)
return;
priv = get_private (self);
priv->state_ps = state;
if (!deferred)
mm_iface_modem_3gpp_apply_deferred_registration_state (self);
}
void
mm_iface_modem_3gpp_update_eps_registration_state (MMIfaceModem3gpp *self,
MMModem3gppRegistrationState state,
gboolean deferred)
{
Private *priv;
gboolean supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &supported,
NULL);
if (!supported)
return;
priv = get_private (self);
priv->state_eps = state;
if (!deferred)
mm_iface_modem_3gpp_apply_deferred_registration_state (self);
}
void
mm_iface_modem_3gpp_update_5gs_registration_state (MMIfaceModem3gpp *self,
MMModem3gppRegistrationState state,
gboolean deferred)
{
Private *priv;
gboolean supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_5GS_NETWORK_SUPPORTED, &supported,
NULL);
if (!supported)
return;
priv = get_private (self);
priv->state_5gs = state;
if (!deferred)
mm_iface_modem_3gpp_apply_deferred_registration_state (self);
}
UPDATE_REGISTRATION_STATE (cs)
UPDATE_REGISTRATION_STATE (ps)
UPDATE_REGISTRATION_STATE (eps)
UPDATE_REGISTRATION_STATE (5gs)
void
mm_iface_modem_3gpp_apply_deferred_registration_state (MMIfaceModem3gpp *self)
@@ -2403,13 +2355,7 @@ reload_initial_eps_bearer_ready (MMIfaceModem3gpp *self,
void
mm_iface_modem_3gpp_reload_initial_eps_bearer (MMIfaceModem3gpp *self)
{
gboolean eps_supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &eps_supported,
NULL);
if (eps_supported &&
if (get_eps_network_supported (self) &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer (
@@ -2513,30 +2459,20 @@ interface_disabling_step (GTask *task)
ctx->step++;
/* fall through */
case DISABLING_STEP_DISABLE_UNSOLICITED_REGISTRATION_EVENTS: {
gboolean cs_supported = FALSE;
gboolean ps_supported = FALSE;
gboolean eps_supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_CS_NETWORK_SUPPORTED, &cs_supported,
MM_IFACE_MODEM_3GPP_PS_NETWORK_SUPPORTED, &ps_supported,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &eps_supported,
NULL);
case DISABLING_STEP_DISABLE_UNSOLICITED_REGISTRATION_EVENTS:
if (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->disable_unsolicited_registration_events &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->disable_unsolicited_registration_events_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->disable_unsolicited_registration_events (
self,
cs_supported,
ps_supported,
eps_supported,
get_cs_network_supported (self),
get_ps_network_supported (self),
get_eps_network_supported (self),
(GAsyncReadyCallback)disable_unsolicited_registration_events_ready,
task);
return;
}
ctx->step++;
} /* fall through */
/* fall through */
case DISABLING_STEP_CLEANUP_UNSOLICITED_REGISTRATION_EVENTS:
if (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->cleanup_unsolicited_registration_events &&
@@ -2844,39 +2780,23 @@ interface_enabling_step (GTask *task)
ctx->step++;
/* fall through */
case ENABLING_STEP_ENABLE_UNSOLICITED_REGISTRATION_EVENTS: {
gboolean cs_supported = FALSE;
gboolean ps_supported = FALSE;
gboolean eps_supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_CS_NETWORK_SUPPORTED, &cs_supported,
MM_IFACE_MODEM_3GPP_PS_NETWORK_SUPPORTED, &ps_supported,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &eps_supported,
NULL);
case ENABLING_STEP_ENABLE_UNSOLICITED_REGISTRATION_EVENTS:
if (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->enable_unsolicited_registration_events &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->enable_unsolicited_registration_events_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->enable_unsolicited_registration_events (
self,
cs_supported,
ps_supported,
eps_supported,
get_cs_network_supported (self),
get_ps_network_supported (self),
get_eps_network_supported (self),
(GAsyncReadyCallback)enable_unsolicited_registration_events_ready,
task);
return;
}
ctx->step++;
} /* fall through */
/* fall through */
case ENABLING_STEP_INITIAL_EPS_BEARER: {
gboolean eps_supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &eps_supported,
NULL);
if (eps_supported &&
case ENABLING_STEP_INITIAL_EPS_BEARER:
if (get_eps_network_supported (self) &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer (
@@ -2886,7 +2806,7 @@ interface_enabling_step (GTask *task)
return;
}
ctx->step++;
} /* fall through */
/* fall through */
case ENABLING_STEP_LAST:
/* We are done without errors! */
@@ -2985,14 +2905,9 @@ sync_eps_bearer (MMIfaceModem3gpp *self,
GTask *task)
{
SyncingContext *ctx;
gboolean eps_supported = FALSE;
g_object_get (self,
MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &eps_supported,
NULL);
/* Refresh EPS bearer if supported */
if (eps_supported &&
if (get_eps_network_supported (self) &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer (