iface-modem: publish helper to abort invocation if state not reached

So that we can use it in other interfaces to abort invocations e.g. if
the modem is not yet enabled.
This commit is contained in:
Aleksander Morgado
2021-04-02 15:05:02 +02:00
parent cc59492caf
commit 7dfe6198e1
2 changed files with 20 additions and 16 deletions
+10 -13
View File
@@ -320,14 +320,11 @@ mm_iface_modem_wait_for_final_state (MMIfaceModem *self,
}
/*****************************************************************************/
/* Helper to return an error when the modem is in failed state and so it
* cannot process a given method invocation
*/
static gboolean
abort_invocation_if_state_not_reached (MMIfaceModem *self,
GDBusMethodInvocation *invocation,
MMModemState minimum_required)
gboolean
mm_iface_modem_abort_invocation_if_state_not_reached (MMIfaceModem *self,
GDBusMethodInvocation *invocation,
MMModemState minimum_required)
{
MMModemState state = MM_MODEM_STATE_UNKNOWN;
@@ -736,7 +733,7 @@ handle_create_bearer_auth_ready (MMBaseModem *self,
return;
}
if (abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_LOCKED)) {
if (mm_iface_modem_abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_LOCKED)) {
handle_create_bearer_context_free (ctx);
return;
}
@@ -944,7 +941,7 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
return;
}
if (abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_LOCKED)) {
if (mm_iface_modem_abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_LOCKED)) {
handle_delete_bearer_context_free (ctx);
return;
}
@@ -1010,7 +1007,7 @@ handle_list_bearers (MmGdbusModem *skeleton,
GStrv paths;
MMBearerList *list = NULL;
if (abort_invocation_if_state_not_reached (self, invocation, MM_MODEM_STATE_LOCKED))
if (mm_iface_modem_abort_invocation_if_state_not_reached (self, invocation, MM_MODEM_STATE_LOCKED))
return TRUE;
g_object_get (self,
@@ -1975,7 +1972,7 @@ handle_enable_auth_ready (MMBaseModem *self,
return;
}
if (abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_LOCKED)) {
if (mm_iface_modem_abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_LOCKED)) {
handle_enable_context_free (ctx);
return;
}
@@ -2845,7 +2842,7 @@ handle_set_current_bands_auth_ready (MMBaseModem *self,
return;
}
if (abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_DISABLED)) {
if (mm_iface_modem_abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_DISABLED)) {
handle_set_current_bands_context_free (ctx);
return;
}
@@ -3231,7 +3228,7 @@ handle_set_current_modes_auth_ready (MMBaseModem *self,
return;
}
if (abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_DISABLED)) {
if (mm_iface_modem_abort_invocation_if_state_not_reached (ctx->self, ctx->invocation, MM_MODEM_STATE_DISABLED)) {
handle_set_current_modes_context_free (ctx);
return;
}
+10 -3
View File
@@ -465,6 +465,16 @@ gboolean mm_iface_modem_disable_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Shutdown Modem interface */
void mm_iface_modem_shutdown (MMIfaceModem *self);
/* Helper to return an error when the modem is in failed state and so it
* cannot process a given method invocation
*/
gboolean mm_iface_modem_abort_invocation_if_state_not_reached (MMIfaceModem *self,
GDBusMethodInvocation *invocation,
MMModemState minimum_required);
/* Allow setting power state */
void mm_iface_modem_set_power_state (MMIfaceModem *self,
MMModemPowerState power_state,
@@ -474,9 +484,6 @@ gboolean mm_iface_modem_set_power_state_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Shutdown Modem interface */
void mm_iface_modem_shutdown (MMIfaceModem *self);
/* Request lock info update.
* It will not only return the lock status, but also set the property values
* in the DBus interface. If 'known_lock' is given, that lock status will be