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:
Aleksander Morgado
2011-11-29 12:05:44 +01:00
parent ddbfad8ca4
commit b31ad37670
2 changed files with 36 additions and 30 deletions

View File

@@ -94,8 +94,8 @@ handle_list_bearers (MmGdbusModem *object,
/*****************************************************************************/ /*****************************************************************************/
static void void
update_state (MMIfaceModem *self, mm_iface_modem_update_state (MMIfaceModem *self,
MMModemState new_state, MMModemState new_state,
MMModemStateReason reason) MMModemStateReason reason)
{ {
@@ -670,7 +670,7 @@ set_lock_status (MMIfaceModem *self,
if (lock == MM_MODEM_LOCK_NONE) { if (lock == MM_MODEM_LOCK_NONE) {
if (old_lock != MM_MODEM_LOCK_NONE) { if (old_lock != MM_MODEM_LOCK_NONE) {
/* Notify transition from UNKNOWN/LOCKED to DISABLED */ /* Notify transition from UNKNOWN/LOCKED to DISABLED */
update_state (self, mm_iface_modem_update_state (self,
MM_MODEM_STATE_DISABLED, MM_MODEM_STATE_DISABLED,
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN); MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
g_idle_add ((GSourceFunc)restart_initialize_idle, self); g_idle_add ((GSourceFunc)restart_initialize_idle, self);
@@ -678,7 +678,7 @@ set_lock_status (MMIfaceModem *self,
} else { } else {
if (old_lock == MM_MODEM_LOCK_UNKNOWN) { if (old_lock == MM_MODEM_LOCK_UNKNOWN) {
/* Notify transition from UNKNOWN to LOCKED */ /* Notify transition from UNKNOWN to LOCKED */
update_state (self, mm_iface_modem_update_state (self,
MM_MODEM_STATE_LOCKED, MM_MODEM_STATE_LOCKED,
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN); MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
} }
@@ -940,7 +940,7 @@ disabling_context_new (MMIfaceModem *self,
NULL); NULL);
g_assert (ctx->skeleton != NULL); g_assert (ctx->skeleton != NULL);
update_state (ctx->self, mm_iface_modem_update_state (ctx->self,
MM_MODEM_STATE_DISABLING, MM_MODEM_STATE_DISABLING,
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED); 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); g_simple_async_result_complete_in_idle (ctx->result);
if (ctx->disabled) if (ctx->disabled)
update_state (ctx->self, mm_iface_modem_update_state (ctx->self,
MM_MODEM_STATE_DISABLED, MM_MODEM_STATE_DISABLED,
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED); MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
else else
/* Fallback to previous state */ /* Fallback to previous state */
update_state (ctx->self, mm_iface_modem_update_state (ctx->self,
ctx->previous_state, ctx->previous_state,
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN); MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
@@ -1137,7 +1137,7 @@ enabling_context_new (MMIfaceModem *self,
NULL); NULL);
g_assert (ctx->skeleton != NULL); g_assert (ctx->skeleton != NULL);
update_state (ctx->self, mm_iface_modem_update_state (ctx->self,
MM_MODEM_STATE_ENABLING, MM_MODEM_STATE_ENABLING,
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED); 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); g_simple_async_result_complete_in_idle (ctx->result);
if (ctx->enabled) if (ctx->enabled)
update_state (ctx->self, mm_iface_modem_update_state (ctx->self,
MM_MODEM_STATE_ENABLED, MM_MODEM_STATE_ENABLED,
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED); MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED);
else { else {
/* Fallback to DISABLED/LOCKED */ /* 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_gdbus_modem_get_unlock_required (ctx->skeleton) == MM_MODEM_LOCK_NONE ?
MM_MODEM_STATE_DISABLED : MM_MODEM_STATE_DISABLED :
MM_MODEM_STATE_LOCKED), MM_MODEM_STATE_LOCKED),

View File

@@ -296,4 +296,9 @@ guint mm_iface_modem_signal_quality_check_finish (MMIfaceModem *self,
gboolean *recent, gboolean *recent,
GError **error); 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 */ #endif /* MM_IFACE_MODEM_H */