diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 48 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.h | 7 |
2 files changed, 54 insertions, 1 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index fed2a5a0..b63b51ae 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -19,6 +19,7 @@ #include <mm-enums-types.h> #include <mm-errors-types.h> +#include "mm-iface-modem.h" #include "mm-iface-modem-3gpp.h" #include "mm-base-modem.h" #include "mm-log.h" @@ -44,6 +45,51 @@ handle_scan (MmGdbusModem3gpp *skeleton, /*****************************************************************************/ +void +mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self, + MMModem3gppRegistrationState new_state) +{ + MMModem3gppRegistrationState previous_state; + + /* Only set new state if different */ + g_object_get (self, + MM_IFACE_MODEM_3GPP_REGISTRATION_STATE, &previous_state, + NULL); + if (new_state == previous_state) + return; + + g_object_set (self, + MM_IFACE_MODEM_3GPP_REGISTRATION_STATE, new_state, + NULL); + + /* TODO: + * While connected we don't want registration status changes to change + * the modem's state away from CONNECTED. + */ + switch (new_state) { + case MM_MODEM_3GPP_REGISTRATION_STATE_HOME: + case MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING: + mm_iface_modem_update_state (MM_IFACE_MODEM (self), + MM_MODEM_STATE_REGISTERED, + MM_MODEM_STATE_REASON_NONE); + break; + case MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING: + mm_iface_modem_update_state (MM_IFACE_MODEM (self), + MM_MODEM_STATE_SEARCHING, + MM_MODEM_STATE_REASON_NONE); + break; + case MM_MODEM_3GPP_REGISTRATION_STATE_IDLE: + case MM_MODEM_3GPP_REGISTRATION_STATE_DENIED: + case MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN: + mm_iface_modem_update_state (MM_IFACE_MODEM (self), + MM_MODEM_STATE_ENABLED, + MM_MODEM_STATE_REASON_NONE); + break; + } +} + +/*****************************************************************************/ + typedef struct _EnablingContext EnablingContext; static void interface_enabling_step (EnablingContext *ctx); @@ -433,7 +479,7 @@ mm_iface_modem_3gpp_get_type (void) &info, 0); - g_type_interface_add_prerequisite (iface_modem_3gpp_type, MM_TYPE_BASE_MODEM); + g_type_interface_add_prerequisite (iface_modem_3gpp_type, MM_TYPE_IFACE_MODEM); } return iface_modem_3gpp_type; diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h index 2fddec6a..f9a2b084 100644 --- a/src/mm-iface-modem-3gpp.h +++ b/src/mm-iface-modem-3gpp.h @@ -89,4 +89,11 @@ gboolean mm_iface_modem_3gpp_enable_finish (MMIfaceModem3gpp *self, /* Shutdown Modem 3GPP interface */ void mm_iface_modem_3gpp_shutdown (MMIfaceModem3gpp *self); +/* Objects implementing this interface can report new registration states. + * This may happen when handling unsolicited registration messages, or when + * the interface asks to run registration state checks. + * Returns FALSE if registration process is still ongoing. */ +void mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self, + MMModem3gppRegistrationState new_state); + #endif /* MM_IFACE_MODEM_3GPP_H */ |