Skip to content
Snippets Groups Projects

postmarketos-base-ui: enable USB tethering v2

Merged Dylan Van Assche requested to merge dylanvanassche/pmaports:usb-tethering-v2 into master
7 files
+ 317
0
Compare changes
  • Side-by-side
  • Inline
Files
7
 
From 50e93872e05b05b311e78c40e13dc197121464f6 Mon Sep 17 00:00:00 2001
 
From: Dylan Van Assche <me@dylanvanassche.be>
 
Date: Mon, 23 Jan 2023 14:46:31 +0100
 
Subject: [PATCH] network: reapply connection on device
 
 
Changing an active connection applies the changes onto the
 
NetworkManager connection, but not on the device. This is because
 
NetworkManager clones the connection when it is applied on a device.
 
This behavior is expected and documented in the NetworkManager
 
documentation [1]. To effectively apply the connection changes onto a
 
device, a reapply operation must be performed. This will make NetworkManager
 
apply the new connection onto the active device without having to
 
disable and re-enable the device.
 
 
Perform this reapply operation when the Apply button is pressed in the
 
Connection Editor so the changes effectively propagate to the network
 
device.
 
 
[1] https://networkmanager.dev/docs/api/1.32.10/gdbus-org.freedesktop.NetworkManager.Device.html#gdbus-method-org-freedesktop-NetworkManager-Device.Reapply
 
---
 
.../connection-editor/net-connection-editor.c | 31 ++++++++++++++++---
 
1 file changed, 27 insertions(+), 4 deletions(-)
 
 
diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c
 
index 03d9fcac0..d567bf1b0 100644
 
--- a/panels/network/connection-editor/net-connection-editor.c
 
+++ b/panels/network/connection-editor/net-connection-editor.c
 
@@ -201,6 +201,25 @@ update_complete (NetConnectionEditor *self,
 
g_signal_emit (self, signals[DONE], 0, success);
 
}
 
 
+static void
 
+device_reapply_cb (GObject *source_object,
 
+ GAsyncResult *res,
 
+ gpointer user_data)
 
+{
 
+ NetConnectionEditor *self;
 
+ g_autoptr(GError) error = NULL;
 
+ gboolean success = TRUE;
 
+
 
+ if (!nm_device_reapply_finish (self->device, res, &error)) {
 
+ g_warning ("Failed to reapply changes on device: %s", error->message);
 
+ success = FALSE;
 
+ }
 
+
 
+ self = user_data;
 
+
 
+ update_complete (self, success);
 
+}
 
+
 
static void
 
updated_connection_cb (GObject *source_object,
 
GAsyncResult *res,
 
@@ -214,13 +233,15 @@ updated_connection_cb (GObject *source_object,
 
res, &error)) {
 
g_warning ("Failed to commit changes: %s", error->message);
 
success = FALSE;
 
- //return; FIXME return if cancelled
 
+ update_complete (self, success);
 
+ return;
 
}
 
 
nm_connection_clear_secrets (NM_CONNECTION (source_object));
 
 
self = user_data;
 
- update_complete (self, success);
 
+ nm_device_reapply_async (self->device, NM_CONNECTION (self->orig_connection),
 
+ 0, 0, NULL, device_reapply_cb, self);
 
}
 
 
static void
 
@@ -236,11 +257,13 @@ added_connection_cb (GObject *source_object,
 
g_warning ("Failed to add connection: %s", error->message);
 
success = FALSE;
 
/* Leave the editor open */
 
- // return; FIXME return if cancelled
 
+ update_complete (self, success);
 
+ return;
 
}
 
 
self = user_data;
 
- update_complete (self, success);
 
+ nm_device_reapply_async (self->device, NM_CONNECTION (self->orig_connection),
 
+ 0, 0, NULL, device_reapply_cb, self);
 
}
 
 
static void
 
--
 
2.39.0
 
Loading