scan flags -> wpa_flags.
[dhcpcd-ui] / src / dhcpcd-qt / dhcpcd-wi.cpp
index f2c3fd3050650a7d115faefa5fb36d18affe809a..3154595e74bafaed459a41c8255000cbba0e748e 100644 (file)
@@ -225,22 +225,26 @@ void DhcpcdWi::dispatch()
 
 void DhcpcdWi::connectSsid(DHCPCD_WI_SCAN *scan)
 {
-       bool ok;
        DHCPCD_WI_SCAN s;
+       const char *psk;
 
        /* Take a copy of scan incase it's destroyed by a scan update */
        memcpy(&s, scan, sizeof(s));
        s.next = NULL;
 
-       QString psk = QInputDialog::getText(dhcpcdQt, s.ssid,
-           tr("Pre Shared key"), QLineEdit::Normal, NULL, &ok);
-
-       if (!ok)
-               return;
+       if (s.flags & WSF_PSK) {
+               bool ok;
+               QString pwd = QInputDialog::getText(dhcpcdQt, s.ssid,
+                   tr("Pre Shared key"), QLineEdit::Normal, NULL, &ok);
+               if (!ok)
+                       return;
+               psk = pwd.toAscii();
+       } else
+               psk = NULL;
 
        QString errt;
 
-       switch (dhcpcd_wpa_configure_psk(wpa, &s, psk.toAscii())) {
+       switch (dhcpcd_wpa_configure_psk(wpa, &s, psk)) {
        case DHCPCD_WPA_SUCCESS:
                return;
        case DHCPCD_WPA_ERR_SET: