From 700e5e544cb2f25aa7526e64edbc36e360cd64cc Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 10 Mar 2017 14:25:33 +0100 Subject: [PATCH] network: Save new SSID to disk before enabling the hotspot Commit e824868 was supposed to do this, but needed to write the changes out to disk before activating the hotspot. https://bugzilla.gnome.org/show_bug.cgi?id=705546 --- panels/network/net-device-wifi.c | 57 +++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c index ae99cd84d..90234b2f6 100644 --- a/panels/network/net-device-wifi.c +++ b/panels/network/net-device-wifi.c @@ -1040,6 +1040,43 @@ net_device_wifi_get_hotspot_connection (NetDeviceWifi *device_wifi) return c; } +static void +overwrite_ssid_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GError *error = NULL; + NMClient *client; + NMRemoteConnection *connection; + NMDevice *device; + NMConnection *c; + NetDeviceWifi *device_wifi; + + connection = NM_REMOTE_CONNECTION (source_object); + + if (!nm_remote_connection_commit_changes_finish (connection, res, &error)) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Failed to save hotspot's settings to disk: %s", + error->message); + g_error_free (error); + return; + } + + device_wifi = user_data; + device = net_device_get_nm_device (NET_DEVICE (device_wifi)); + client = net_object_get_client (NET_OBJECT (device_wifi)); + c = net_device_wifi_get_hotspot_connection (device_wifi); + + g_debug ("activate existing hotspot connection\n"); + nm_client_activate_connection_async (client, + c, + device, + NULL, + NULL, + activate_cb, + device_wifi); +} + static void start_shared_connection (NetDeviceWifi *device_wifi) { @@ -1066,19 +1103,23 @@ start_shared_connection (NetDeviceWifi *device_wifi) client = net_object_get_client (NET_OBJECT (device_wifi)); if (c != NULL) { NMSettingWireless *sw; + const char *c_path; + NMRemoteConnection *connection; sw = nm_connection_get_setting_wireless (c); g_object_set (sw, "ssid", ssid, NULL); g_bytes_unref (ssid); - g_debug ("activate existing hotspot connection\n"); - nm_client_activate_connection_async (client, - c, - device, - NULL, - NULL, - activate_cb, - device_wifi); + c_path = nm_connection_get_path (c); + connection = nm_client_get_connection_by_path (client, c_path); + + g_debug ("overwriting ssid to %s", (char *) g_bytes_get_data (ssid, NULL)); + + nm_remote_connection_commit_changes_async (connection, + TRUE, + NULL, + overwrite_ssid_cb, + device_wifi); return; }