aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-11-29 12:08:44 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:29 +0100
commit9b796e0d86e33847225450139e30fe4a59ce4a4a (patch)
treea83005f4c7c726a1756b83342f2117885dde0daf /src
parentb31ad376704d007a69b9b6ba85e3fb01a510731c (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-3gpp.c48
-rw-r--r--src/mm-iface-modem-3gpp.h7
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 */