[PATCH 3/5] hso: make report_connection_status() a separate logical block
Aleksander Morgado
aleksander at aleksander.es
Tue Nov 21 18:24:38 UTC 2017
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.
---
plugins/option/mm-broadband-bearer-hso.c | 64 ++++++++++++++++++--------------
1 file 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)
--
2.15.0
More information about the ModemManager-devel
mailing list