File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 108
108
wpa_configure (DHCPCD_WPA * wpa , DHCPCD_WI_SCAN * scan )
109
109
{
110
110
DHCPCD_WI_SCAN s ;
111
+ DHCPCD_IF * i ;
111
112
GtkWidget * label , * psk , * vbox , * hbox ;
112
113
const char * var ;
113
114
int result ;
@@ -117,6 +118,14 @@ wpa_configure(DHCPCD_WPA *wpa, DHCPCD_WI_SCAN *scan)
117
118
memcpy (& s , scan , sizeof (s ));
118
119
s .next = NULL ;
119
120
121
+ i = dhcpcd_wpa_if (wpa );
122
+ if (i == NULL )
123
+ return false;
124
+
125
+ /* Disconnect if same interface selected */
126
+ if (dhcpcd_wi_associated (i , & s ))
127
+ return dhcpcd_wpa_disconnect (wpa );
128
+
120
129
if (!(s .flags & WSF_PSK ))
121
130
return wpa_conf (dhcpcd_wpa_configure (wpa , & s , NULL ));
122
131
Original file line number Diff line number Diff line change @@ -295,13 +295,23 @@ void DhcpcdWi::ping()
295
295
void DhcpcdWi::connectSsid (DHCPCD_WI_SCAN *scan)
296
296
{
297
297
DHCPCD_WI_SCAN s;
298
+ DHCPCD_IF *i;
298
299
int err;
299
300
300
301
/* Take a copy of scan incase it's destroyed by a scan update */
301
302
memcpy (&s, scan, sizeof (s));
302
303
s.next = NULL ;
303
304
304
- if (s.flags & WSF_PSK) {
305
+ i = dhcpcd_wpa_if (wpa);
306
+ if (i == NULL )
307
+ err = DHCPCD_WPA_ERR;
308
+ else if (dhcpcd_wi_associated (i, &s)) {
309
+ /* Disconnect if same interface selected */
310
+ if (!dhcpcd_wpa_disconnect (wpa))
311
+ err = DHCPCD_WPA_ERR_DISCONN;
312
+ else
313
+ err = DHCPCD_WPA_SUCCESS;
314
+ } else if (s.flags & WSF_PSK) {
305
315
bool ok;
306
316
QString pwd;
307
317
@@ -322,11 +332,14 @@ void DhcpcdWi::connectSsid(DHCPCD_WI_SCAN *scan)
322
332
switch (err) {
323
333
case DHCPCD_WPA_SUCCESS:
324
334
return ;
335
+ case DHCPCD_WPA_ERR:
336
+ errt = tr (" Failed." );
337
+ break ;
325
338
case DHCPCD_WPA_ERR_DISCONN:
326
339
errt = tr (" Failed to disconnect." );
327
340
break ;
328
341
case DHCPCD_WPA_ERR_RECONF:
329
- errt = tr (" Faile to reconfigure." );
342
+ errt = tr (" Failed to reconfigure." );
330
343
break ;
331
344
case DHCPCD_WPA_ERR_SET:
332
345
errt = tr (" Failed to set key management." );
You can’t perform that action at this time.
0 commit comments