iface-modem-3gpp: allow changing the RegistrationState from outside the interface

The 3GPP registration state will always be set from outside the 3GPP interface,
for example when parsing unsolicited registration messages, on when the
interface requests manual checking of registration state.

We'll also update the State property in the Modem interface when we switch to a
connected state, so we also set the Modem interface as a prerrequisite of the
3GPP interface.
This commit is contained in:
Aleksander Morgado
2012-03-15 14:14:29 +01:00
parent b31ad37670
commit 9b796e0d86
2 changed files with 54 additions and 1 deletions
+47 -1
View File
@@ -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;
+7
View File
@@ -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 */