summaryrefslogtreecommitdiff
path: root/src/mm-base-bearer.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-05-18 16:00:35 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-05-23 01:22:07 +0200
commit7e8885d569d20259d1ae9f3c8c890ae9d4a2cd4d (patch)
treed7adc649d1ab9f38e4a7dfe5557695b62b5bf7fd /src/mm-base-bearer.c
parentde6b1324cb80413e552806f75c70be72cc41e933 (diff)
base-bearer: report connection error on failed connection attempts
When a user-requested connection attempt fails, we not only return the connection error to the user that requested it, we also publish the specific connection error in DBus for others to check why the failure happened.
Diffstat (limited to 'src/mm-base-bearer.c')
-rw-r--r--src/mm-base-bearer.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/mm-base-bearer.c b/src/mm-base-bearer.c
index a8f8a262..e65799c3 100644
--- a/src/mm-base-bearer.c
+++ b/src/mm-base-bearer.c
@@ -243,6 +243,19 @@ connection_monitor_start (MMBaseBearer *self)
/*****************************************************************************/
static void
+bearer_update_connection_error (MMBaseBearer *self,
+ const GError *connection_error)
+{
+ g_autoptr(GVariant) tuple = NULL;
+
+ if (connection_error)
+ tuple = mm_common_error_to_tuple (connection_error);
+ mm_gdbus_bearer_set_connection_error (MM_GDBUS_BEARER (self), tuple);
+}
+
+/*****************************************************************************/
+
+static void
bearer_update_interface_stats (MMBaseBearer *self)
{
mm_gdbus_bearer_set_stats (
@@ -815,8 +828,11 @@ connect_ready (MMBaseBearer *self,
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
/* Will launch disconnection */
launch_disconnect = TRUE;
- } else
+ } else {
+ /* Update reported connection error before the status update */
+ bearer_update_connection_error (self, error);
bearer_update_status (self, MM_BEARER_STATUS_DISCONNECTED);
+ }
}
/* Handle cancellations detected after successful connection */
else if (g_cancellable_is_cancelled (self->priv->connect_cancellable)) {
@@ -841,6 +857,8 @@ connect_ready (MMBaseBearer *self,
}
if (launch_disconnect) {
+ /* Update reported connection error before the status update */
+ bearer_update_connection_error (self, error);
bearer_update_status (self, MM_BEARER_STATUS_DISCONNECTING);
MM_BASE_BEARER_GET_CLASS (self)->disconnect (
self,