summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2017-03-10 14:25:33 +0100
committerBastien Nocera <hadess@hadess.net>2017-03-14 11:10:56 +0100
commit40869de375d7fcf38a717fb5e1196ae84633e4d5 (patch)
treefbd49138a047c750c235cc5ba3e6246579e0921a
parente41134671baf56f747de68884c8f030948e8b07d (diff)
downloadgnome-control-center-40869de375d7fcf38a717fb5e1196ae84633e4d5.tar.gz
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
-rw-r--r--panels/network/net-device-wifi.c57
1 files 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
@@ -1041,6 +1041,43 @@ net_device_wifi_get_hotspot_connection (NetDeviceWifi *device_wifi)
}
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)
{
NMConnection *c;
@@ -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;
}