aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/option/mm-broadband-bearer-hso.c4
-rw-r--r--src/mm-bearer.c28
-rw-r--r--src/mm-bearer.h5
-rw-r--r--src/mm-broadband-bearer.c42
4 files changed, 59 insertions, 20 deletions
diff --git a/plugins/option/mm-broadband-bearer-hso.c b/plugins/option/mm-broadband-bearer-hso.c
index 13b40cd7..1d8e1d19 100644
--- a/plugins/option/mm-broadband-bearer-hso.c
+++ b/plugins/option/mm-broadband-bearer-hso.c
@@ -382,9 +382,7 @@ mm_broadband_bearer_hso_report_connection_status (MMBroadbandBearerHso *self,
dial_3gpp_context_complete_and_free (ctx);
} else {
/* Just ensure we mark ourselves as being disconnected... */
- g_object_set (self,
- MM_BEARER_STATUS, MM_BEARER_STATUS_DISCONNECTED,
- NULL);
+ mm_bearer_report_disconnection (MM_BEARER (self));
}
break;
}
diff --git a/src/mm-bearer.c b/src/mm-bearer.c
index f738f389..c0b8c332 100644
--- a/src/mm-bearer.c
+++ b/src/mm-bearer.c
@@ -671,6 +671,22 @@ mm_bearer_disconnect_force (MMBearer *self)
/*****************************************************************************/
+static void
+report_disconnection (MMBearer *self)
+{
+ /* In the generic bearer implementation we just need to reset the
+ * interface status */
+ bearer_update_status (self, MM_BEARER_STATUS_DISCONNECTED);
+}
+
+void
+mm_bearer_report_disconnection (MMBearer *self)
+{
+ return MM_BEARER_GET_CLASS (self)->report_disconnection (self);
+}
+
+/*****************************************************************************/
+
gboolean
mm_bearer_cmp_properties (MMBearer *self,
MMBearerProperties *properties)
@@ -719,12 +735,8 @@ set_property (GObject *object,
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
break;
case PROP_STATUS:
- self->priv->status = g_value_get_enum (value);
-
- /* Ensure that we don't expose any connection related data in the
- * interface when going into disconnected state. */
- if (self->priv->status == MM_BEARER_STATUS_DISCONNECTED)
- bearer_reset_interface_status (self);
+ /* We don't allow g_object_set()-ing the status property */
+ g_assert_not_reached ();
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -819,6 +831,8 @@ mm_bearer_class_init (MMBearerClass *klass)
object_class->finalize = finalize;
object_class->dispose = dispose;
+ klass->report_disconnection = report_disconnection;
+
properties[PROP_CONNECTION] =
g_param_spec_object (MM_BEARER_CONNECTION,
"Connection",
@@ -849,6 +863,6 @@ mm_bearer_class_init (MMBearerClass *klass)
"Status of the bearer",
MM_TYPE_BEARER_STATUS,
MM_BEARER_STATUS_DISCONNECTED,
- G_PARAM_READWRITE);
+ G_PARAM_READABLE);
g_object_class_install_property (object_class, PROP_STATUS, properties[PROP_STATUS]);
}
diff --git a/src/mm-bearer.h b/src/mm-bearer.h
index 84fbcb37..6f35e2d7 100644
--- a/src/mm-bearer.h
+++ b/src/mm-bearer.h
@@ -76,6 +76,9 @@ struct _MMBearerClass {
GAsyncResult *res,
GError **error);
+ /* Report disconnection */
+ void (* report_disconnection) (MMBearer *bearer);
+
/* Check if the bearer has the exact same properties */
gboolean (* cmp_properties) (MMBearer *self,
MMBearerProperties *properties);
@@ -111,6 +114,8 @@ gboolean mm_bearer_disconnect_finish (MMBearer *self,
void mm_bearer_disconnect_force (MMBearer *self);
+void mm_bearer_report_disconnection (MMBearer *self);
+
gboolean mm_bearer_cmp_properties (MMBearer *self,
MMBearerProperties *properties);
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index bd9c36b7..a90360b9 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -1602,21 +1602,30 @@ disconnect_finish (MMBearer *self,
}
static void
-disconnect_succeeded (DisconnectContext *ctx)
+reset_bearer_connection (MMBroadbandBearer *self)
{
- /* If properly disconnected, close the data port */
- if (MM_IS_AT_SERIAL_PORT (ctx->data))
- mm_serial_port_close (MM_SERIAL_PORT (ctx->data));
+ if (self->priv->port) {
+ /* If properly disconnected, close the data port */
+ if (MM_IS_AT_SERIAL_PORT (self->priv->port))
+ mm_serial_port_close (MM_SERIAL_PORT (self->priv->port));
- /* Port is disconnected; update the state. Note: implementations may
- * already have set the port as disconnected (e.g the 3GPP one) */
- mm_port_set_connected (ctx->data, FALSE);
+ /* Port is disconnected; update the state. Note: implementations may
+ * already have set the port as disconnected (e.g the 3GPP one) */
+ mm_port_set_connected (self->priv->port, FALSE);
- /* Clear data port */
- g_clear_object (&ctx->self->priv->port);
+ /* Clear data port */
+ g_clear_object (&self->priv->port);
+ }
/* Reset current connection type */
- ctx->self->priv->connection_type = CONNECTION_TYPE_NONE;
+ self->priv->connection_type = CONNECTION_TYPE_NONE;
+}
+
+static void
+disconnect_succeeded (DisconnectContext *ctx)
+{
+ /* Cleanup all connection related data */
+ reset_bearer_connection (ctx->self);
/* Set operation result */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
@@ -1746,6 +1755,18 @@ disconnect (MMBearer *self,
/*****************************************************************************/
+static void
+report_disconnection (MMBearer *self)
+{
+ /* Cleanup all connection related data */
+ reset_bearer_connection (MM_BROADBAND_BEARER (self));
+
+ /* Chain up parent's report_disconection() */
+ MM_BEARER_CLASS (mm_broadband_bearer_parent_class)->report_disconnection (self);
+}
+
+/*****************************************************************************/
+
static gboolean
cmp_properties (MMBearer *self,
MMBearerProperties *properties)
@@ -2241,6 +2262,7 @@ mm_broadband_bearer_class_init (MMBroadbandBearerClass *klass)
bearer_class->connect_finish = connect_finish;
bearer_class->disconnect = disconnect;
bearer_class->disconnect_finish = disconnect_finish;
+ bearer_class->report_disconnection = report_disconnection;
klass->connect_3gpp = connect_3gpp;
klass->connect_3gpp_finish = detailed_connect_finish;