diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2022-09-16 10:31:35 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-09-20 14:09:41 +0000 |
commit | 7b0b3e7e48ea32be2f88677f2c6e18cf040815db (patch) | |
tree | 628a27480752ac0b72fdb3c3924d56dd4a83f09e | |
parent | 1fa67b3842d4bda8ec2c27dedc231f462f6d105f (diff) |
iface-modem-3gpp: helpers to check if specific domains are supported
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 225 |
1 files changed, 70 insertions, 155 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index 43a109a7..5c05178e 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -107,6 +107,25 @@ get_private (MMIfaceModem3gpp *self) } /*****************************************************************************/ + +#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 */ typedef struct { @@ -1734,32 +1753,30 @@ handle_set_nr5g_registration_settings (MmGdbusModem3gpp *skeleton, /*****************************************************************************/ gboolean -mm_iface_modem_3gpp_run_registration_checks_finish (MMIfaceModem3gpp *self, - GAsyncResult *res, - GError **error) +mm_iface_modem_3gpp_run_registration_checks_finish (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error) { g_assert (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->run_registration_checks_finish != NULL); return MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->run_registration_checks_finish (self, res, error); } void -mm_iface_modem_3gpp_run_registration_checks (MMIfaceModem3gpp *self, - GAsyncReadyCallback callback, - gpointer user_data) +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); -} - -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); -} +#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); \ + } + +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 */ - - case ENABLING_STEP_INITIAL_EPS_BEARER: { - gboolean eps_supported = FALSE; - - g_object_get (self, - MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, &eps_supported, - NULL); + /* fall through */ - 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 ( |