bearer: set signal handlers only after setting 'config' and 'modem' properties

Modem plugins may set the 'modem' property before the 'config' property when
creating a bearer. set_signal_handlers() should thus be called after both
properties are set such that modem_{3gpp,cdma}_registration_state_changed
checks roaming allowance correctly when launching a connection.

Based on a draft patch by:
  Ben Chan <benchan@chromium.org>
This commit is contained in:
Aleksander Morgado
2012-09-05 18:31:51 -07:00
parent e3152772e5
commit 4c2951692c

View File

@@ -250,8 +250,12 @@ static void
set_signal_handlers (MMBearer *self) set_signal_handlers (MMBearer *self)
{ {
g_assert (self->priv->modem != NULL); g_assert (self->priv->modem != NULL);
g_assert (self->priv->config != NULL);
if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (self->priv->modem))) { /* Don't set the 3GPP registration change signal handlers if they
* are already set. */
if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (self->priv->modem)) &&
!self->priv->id_3gpp_registration_change) {
self->priv->id_3gpp_registration_change = self->priv->id_3gpp_registration_change =
g_signal_connect (self->priv->modem, g_signal_connect (self->priv->modem,
"notify::" MM_IFACE_MODEM_3GPP_REGISTRATION_STATE, "notify::" MM_IFACE_MODEM_3GPP_REGISTRATION_STATE,
@@ -260,7 +264,11 @@ set_signal_handlers (MMBearer *self)
modem_3gpp_registration_state_changed (MM_IFACE_MODEM_3GPP (self->priv->modem), NULL, self); modem_3gpp_registration_state_changed (MM_IFACE_MODEM_3GPP (self->priv->modem), NULL, self);
} }
if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (self->priv->modem))) { /* Don't set the CDMA1x/EV-DO registration change signal handlers if they
* are already set. */
if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (self->priv->modem)) &&
!self->priv->id_cdma1x_registration_change &&
!self->priv->id_evdo_registration_change) {
self->priv->id_cdma1x_registration_change = self->priv->id_cdma1x_registration_change =
g_signal_connect (self->priv->modem, g_signal_connect (self->priv->modem,
"notify::" MM_IFACE_MODEM_CDMA_CDMA1X_REGISTRATION_STATE, "notify::" MM_IFACE_MODEM_CDMA_CDMA1X_REGISTRATION_STATE,
@@ -911,10 +919,12 @@ set_property (GObject *object,
g_object_bind_property (self->priv->modem, MM_BASE_MODEM_CONNECTION, g_object_bind_property (self->priv->modem, MM_BASE_MODEM_CONNECTION,
self, MM_BEARER_CONNECTION, self, MM_BEARER_CONNECTION,
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
if (self->priv->config) {
/* Listen to 3GPP/CDMA registration state changes */ /* Listen to 3GPP/CDMA registration state changes. We need both
* 'config' and 'modem' set. */
set_signal_handlers (self); set_signal_handlers (self);
} }
}
break; break;
case PROP_STATUS: case PROP_STATUS:
/* We don't allow g_object_set()-ing the status property */ /* We don't allow g_object_set()-ing the status property */
@@ -925,6 +935,11 @@ set_property (GObject *object,
g_clear_object (&self->priv->config); g_clear_object (&self->priv->config);
self->priv->config = g_value_dup_object (value); self->priv->config = g_value_dup_object (value);
if (self->priv->modem) {
/* Listen to 3GPP/CDMA registration state changes. We need both
* 'config' and 'modem' set. */
set_signal_handlers (self);
}
/* Also expose the properties */ /* Also expose the properties */
dictionary = mm_bearer_properties_get_dictionary (self->priv->config); dictionary = mm_bearer_properties_get_dictionary (self->priv->config);
mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (self), dictionary); mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (self), dictionary);