diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-11-21 14:23:20 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-12-05 10:55:41 +0100 |
commit | 09d563fd346b22700f22d9d1466881ad0e3d9764 (patch) | |
tree | 938a45c2934282306d6a6146bda75b3987346e07 /plugins | |
parent | b6e3cb463d2515ac9efc28346776a3ccbd7a0802 (diff) |
hso: make report_connection_status() a separate logical block
This block is a subclassed method from MMBaseBearer, which we just
happen to also use as part of the 3GPP dial logic in the connection
attempt.
So make it a separate logical block, and call the processing of the
connection attempt if one is found.
This change makes it similar to the same logic in the Icera plugin.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/option/mm-broadband-bearer-hso.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/plugins/option/mm-broadband-bearer-hso.c b/plugins/option/mm-broadband-bearer-hso.c index 2e2b9364..96e602df 100644 --- a/plugins/option/mm-broadband-bearer-hso.c +++ b/plugins/option/mm-broadband-bearer-hso.c @@ -286,39 +286,17 @@ connect_reset (GTask *task) } static void -report_connection_status (MMBaseBearer *_self, - MMBearerConnectionStatus status) +process_pending_connect_attempt (MMBroadbandBearerHso *self, + MMBearerConnectionStatus status) { - MMBroadbandBearerHso *self = MM_BROADBAND_BEARER_HSO (_self); - GTask *task; - Dial3gppContext *ctx; - - g_assert (status == MM_BEARER_CONNECTION_STATUS_CONNECTED || - status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED || - status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED); + GTask *task; + Dial3gppContext *ctx; - /* Recover task (if any) and remove both cancellation and timeout (if any)*/ + /* Recover task and remove both cancellation and timeout (if any)*/ + g_assert (self->priv->connect_pending); task = self->priv->connect_pending; self->priv->connect_pending = NULL; - /* Connection status reported but no connection attempt? */ - if (!task) { - g_assert (!self->priv->connect_pending_id); - g_assert (!self->priv->connect_port_closed_id); - - mm_dbg ("Received spontaneous _OWANCALL (%s)", - mm_bearer_connection_status_get_string (status)); - - if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED) { - /* If no connection attempt on-going, make sure we mark ourselves as - * disconnected */ - MM_BASE_BEARER_CLASS (mm_broadband_bearer_hso_parent_class)->report_connection_status ( - _self, - status); - } - return; - } - ctx = g_task_get_task_data (task); if (self->priv->connect_pending_id) { @@ -717,6 +695,36 @@ disconnect_3gpp (MMBroadbandBearer *self, /*****************************************************************************/ +static void +report_connection_status (MMBaseBearer *_self, + MMBearerConnectionStatus status) +{ + MMBroadbandBearerHso *self = MM_BROADBAND_BEARER_HSO (_self); + + g_assert (status == MM_BEARER_CONNECTION_STATUS_CONNECTED || + status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED || + status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED); + + /* Process pending connection attempt */ + if (self->priv->connect_pending) { + process_pending_connect_attempt (self, status); + return; + } + + mm_dbg ("Received spontaneous _OWANCALL (%s)", + mm_bearer_connection_status_get_string (status)); + + if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED) { + /* If no connection attempt on-going, make sure we mark ourselves as + * disconnected */ + MM_BASE_BEARER_CLASS (mm_broadband_bearer_hso_parent_class)->report_connection_status ( + _self, + status); + } +} + +/*****************************************************************************/ + MMBaseBearer * mm_broadband_bearer_hso_new_finish (GAsyncResult *res, GError **error) |