SLOT(tabChanged(int)));
connect(wpsPbcButton, SIGNAL(clicked()), this, SLOT(wpsPbc()));
connect(wpsPinButton, SIGNAL(clicked()), this, SLOT(wpsGeneratePin()));
+ connect(wpsApPinEdit, SIGNAL(textChanged(const QString &)), this,
+ SLOT(wpsApPinChanged(const QString &)));
+ connect(wpsApPinButton, SIGNAL(clicked()), this, SLOT(wpsApPin()));
eh = NULL;
scanres = NULL;
char reply[10];
size_t reply_len = sizeof(reply);
ctrlRequest("DISCONNECT", reply, &reply_len);
-
- if (wpsRunning)
- wpsStatusText->setText("Stopped");
- else
- wpsStatusText->setText("");
- wpsPinEdit->setEnabled(false);
- wpsInstructions->setText("");
- wpsRunning = false;
+ stopWpsRun(false);
}
showTrayMessage(QSystemTrayIcon::Information, 3,
"Connection to network established.");
QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
- if (wpsRunning) {
- wpsStatusText->setText("Connected to the network");
- wpsPinEdit->setEnabled(false);
- wpsInstructions->setText("");
- wpsRunning = false;
- }
+ stopWpsRun(true);
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PBC)) {
showTrayMessage(QSystemTrayIcon::Information, 3,
"Wi-Fi Protected Setup (WPS) AP\n"
cmd.prepend("SELECT_NETWORK ");
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
triggerUpdate();
-
- if (wpsRunning)
- wpsStatusText->setText("Stopped");
- else
- wpsStatusText->setText("");
- wpsPinEdit->setEnabled(false);
- wpsInstructions->setText("");
- wpsRunning = false;
+ stopWpsRun(false);
}
if (wpsRunning)
return;
- /* TODO: Update WPS status based on latest scan results and
- * availability of WPS APs */
+ wpsApPinEdit->setEnabled(!bssFromScan.isEmpty());
+ if (bssFromScan.isEmpty())
+ wpsApPinButton->setEnabled(false);
}
wpsStatusText->setText("Waiting for Registrar");
wpsRunning = true;
}
+
+
+void WpaGui::setBssFromScan(const QString &bssid)
+{
+ bssFromScan = bssid;
+ wpsApPinEdit->setEnabled(!bssFromScan.isEmpty());
+ wpsApPinButton->setEnabled(wpsApPinEdit->text().length() == 8);
+ wpsStatusText->setText("WPS AP selected from scan results");
+ wpsInstructions->setText("If you want to use an AP device PIN, e.g., "
+ "from a label in the device, enter the eight "
+ "digit AP PIN and click Use AP PIN button.");
+}
+
+
+void WpaGui::wpsApPinChanged(const QString &text)
+{
+ wpsApPinButton->setEnabled(text.length() == 8);
+}
+
+
+void WpaGui::wpsApPin()
+{
+ char reply[20];
+ size_t reply_len = sizeof(reply);
+
+ QString cmd("WPS_REG " + bssFromScan + " " + wpsApPinEdit->text());
+ if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) < 0)
+ return;
+
+ wpsStatusText->setText("Waiting for AP/Enrollee");
+ wpsRunning = true;
+}
+
+
+void WpaGui::stopWpsRun(bool success)
+{
+ if (wpsRunning)
+ wpsStatusText->setText(success ? "Connected to the network" :
+ "Stopped");
+ else
+ wpsStatusText->setText("");
+ wpsPinEdit->setEnabled(false);
+ wpsInstructions->setText("");
+ wpsRunning = false;
+ bssFromScan = "";
+ wpsApPinEdit->setEnabled(false);
+ wpsApPinButton->setEnabled(false);
+}