@@ -231,11 +231,7 @@ public class Network.WifiInterface : Network.WidgetNMInterface {
231231 }
232232 }
233233
234- private async void wifi_activate_cb (WifiMenuItem i ) {
235- if (device == null ) {
236- return ;
237- }
238-
234+ private async void wifi_activate_cb (WifiMenuItem i ) requires (device != null ) {
239235 /* Do not activate connection if it is already activated */
240236 if (wifi_device. get_active_access_point () == i. ap) {
241237 return ;
@@ -263,47 +259,54 @@ public class Network.WifiInterface : Network.WidgetNMInterface {
263259 return ;
264260 }
265261
266- var flags = i. ap. get_wpa_flags () | i. ap. get_rsn_flags ();
267- var is_secured = flags != NM . @80211ApSecurityFlags. NONE ;
262+ // Always create a proper connection and wireless setting for libnma
263+ var s_con = new NM .SettingConnection () {
264+ id = NM.Utils.ssid_to_utf8 (i .ap .get_ssid ().get_data ()),
265+ uuid = NM.Utils.uuid_generate (),
266+ type = NM.SettingWireless.SETTING_NAME
267+ };
268268
269- var connection = NM . SimpleConnection . new ();
269+ var s_wifi = new NM .SettingWireless () {
270+ ssid = i.ap.get_ssid ()
271+ };
270272
271- // Always create a proper connection and wireless setting for libnma
272- var s_con = new NM .SettingConnection ();
273- s_con. uuid = NM . Utils . uuid_generate ();
274- s_con. id = NM . Utils . ssid_to_utf8 (i. ap. get_ssid (). get_data ());
275- s_con. type = NM . SettingWireless . SETTING_NAME ;
273+ var connection = NM.SimpleConnection.new ();
276274 connection.add_setting (s_con );
277-
278- var s_wifi = new NM .SettingWireless ();
279- s_wifi. ssid = i. ap. get_ssid ();
280275 connection.add_setting (s_wifi );
281276
282- if (is_secured) {
277+ var flags = i.ap.get_wpa_flags () | i.ap.get_rsn_flags ();
278+ if (flags != NM .@80211ApSecurityFlags .NONE ) {
283279 if (NM . @80211ApSecurityFlags. KEY_MGMT_OWE in flags ||
284280 NM . @80211ApSecurityFlags. KEY_MGMT_OWE_TM in flags) {
285- var s_wsec = new NM .SettingWirelessSecurity ();
286- s_wsec. key_mgmt = " owe" ;
281+ var s_wsec = new NM .SettingWirelessSecurity () {
282+ key_mgmt = " owe"
283+ };
284+
287285 connection. add_setting (s_wsec);
288286 }
289287
290288 if (NM . @80211ApSecurityFlags. KEY_MGMT_SAE in flags) {
291- var s_wsec = new NM .SettingWirelessSecurity ();
292- s_wsec. key_mgmt = " sae" ;
289+ var s_wsec = new NM .SettingWirelessSecurity () {
290+ key_mgmt = " sae"
291+ };
292+
293293 connection. add_setting (s_wsec);
294294 }
295295
296296 // If the AP is WPA[2]-Enterprise then we need to set up a minimal 802.1x setting before
297297 // prompting the user to configure the authentication, otherwise, the dialog works out
298298 // what sort of credentials to prompt for automatically
299299 if (NM . @80211ApSecurityFlags. KEY_MGMT_802_1X in flags) {
300- var s_wsec = new NM .SettingWirelessSecurity ();
301- s_wsec . key_mgmt = " wpa-eap" ;
302- connection . add_setting (s_wsec) ;
300+ var s_wsec = new NM .SettingWirelessSecurity () {
301+ key_mgmt = " wpa-eap"
302+ } ;
303303
304- var s_8021x = new NM .Setting8021x ();
304+ var s_8021x = new NM .Setting8021x () {
305+ phase2_auth = " mschapv2"
306+ };
305307 s_8021x. add_eap_method (" ttls" );
306- s_8021x. phase2_auth = " mschapv2" ;
308+
309+ connection. add_setting (s_wsec);
307310 connection. add_setting (s_8021x);
308311 }
309312
0 commit comments