iface-modem: allow changing the State from outside the interface
Some states need to be set from outside the scope of the Modem interface, like Registration-related ones (REGISTERED, SEARCHING, ...) or Connection-related ones (CONNECTED, ...).
This commit is contained in:
@@ -94,8 +94,8 @@ handle_list_bearers (MmGdbusModem *object,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
update_state (MMIfaceModem *self,
|
||||
void
|
||||
mm_iface_modem_update_state (MMIfaceModem *self,
|
||||
MMModemState new_state,
|
||||
MMModemStateReason reason)
|
||||
{
|
||||
@@ -670,7 +670,7 @@ set_lock_status (MMIfaceModem *self,
|
||||
if (lock == MM_MODEM_LOCK_NONE) {
|
||||
if (old_lock != MM_MODEM_LOCK_NONE) {
|
||||
/* Notify transition from UNKNOWN/LOCKED to DISABLED */
|
||||
update_state (self,
|
||||
mm_iface_modem_update_state (self,
|
||||
MM_MODEM_STATE_DISABLED,
|
||||
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
|
||||
g_idle_add ((GSourceFunc)restart_initialize_idle, self);
|
||||
@@ -678,7 +678,7 @@ set_lock_status (MMIfaceModem *self,
|
||||
} else {
|
||||
if (old_lock == MM_MODEM_LOCK_UNKNOWN) {
|
||||
/* Notify transition from UNKNOWN to LOCKED */
|
||||
update_state (self,
|
||||
mm_iface_modem_update_state (self,
|
||||
MM_MODEM_STATE_LOCKED,
|
||||
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
|
||||
}
|
||||
@@ -940,7 +940,7 @@ disabling_context_new (MMIfaceModem *self,
|
||||
NULL);
|
||||
g_assert (ctx->skeleton != NULL);
|
||||
|
||||
update_state (ctx->self,
|
||||
mm_iface_modem_update_state (ctx->self,
|
||||
MM_MODEM_STATE_DISABLING,
|
||||
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
|
||||
|
||||
@@ -953,12 +953,12 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
|
||||
if (ctx->disabled)
|
||||
update_state (ctx->self,
|
||||
mm_iface_modem_update_state (ctx->self,
|
||||
MM_MODEM_STATE_DISABLED,
|
||||
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
|
||||
else
|
||||
/* Fallback to previous state */
|
||||
update_state (ctx->self,
|
||||
mm_iface_modem_update_state (ctx->self,
|
||||
ctx->previous_state,
|
||||
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
|
||||
|
||||
@@ -1137,7 +1137,7 @@ enabling_context_new (MMIfaceModem *self,
|
||||
NULL);
|
||||
g_assert (ctx->skeleton != NULL);
|
||||
|
||||
update_state (ctx->self,
|
||||
mm_iface_modem_update_state (ctx->self,
|
||||
MM_MODEM_STATE_ENABLING,
|
||||
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
|
||||
|
||||
@@ -1150,12 +1150,13 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
|
||||
if (ctx->enabled)
|
||||
update_state (ctx->self,
|
||||
mm_iface_modem_update_state (ctx->self,
|
||||
MM_MODEM_STATE_ENABLED,
|
||||
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
|
||||
else {
|
||||
/* Fallback to DISABLED/LOCKED */
|
||||
update_state (ctx->self,
|
||||
mm_iface_modem_update_state (
|
||||
ctx->self,
|
||||
(mm_gdbus_modem_get_unlock_required (ctx->skeleton) == MM_MODEM_LOCK_NONE ?
|
||||
MM_MODEM_STATE_DISABLED :
|
||||
MM_MODEM_STATE_LOCKED),
|
||||
|
@@ -296,4 +296,9 @@ guint mm_iface_modem_signal_quality_check_finish (MMIfaceModem *self,
|
||||
gboolean *recent,
|
||||
GError **error);
|
||||
|
||||
/* Allow reporting new modem state */
|
||||
void mm_iface_modem_update_state (MMIfaceModem *self,
|
||||
MMModemState new_state,
|
||||
MMModemStateReason reason);
|
||||
|
||||
#endif /* MM_IFACE_MODEM_H */
|
||||
|
Reference in New Issue
Block a user