Exemplo n.º 1
0
bool WpsPbc::post_next()
{
	bool ret = false;
	if (!wiz->pbNext->text().compare("&Next")) {
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
		ret = true;
	} else {
		do {
			if (!MainProcess::startPbc()) {
				MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
				QMessageBox::warning(this, label->text(),
									 "Could not start WPS authentication with PBC method\n");
				wiz->pbNext->setText("&Start");
				break;
			} else {
				progressBar->setValue(0);
				progressBar->setVisible(true);
				timer->start(100);
				wiz->pbNext->setText("&Restart");
			}
			lblComment->setText("Try to authenticate with PBC method in 2 minutes\n");
		} while (0);
	}

	return ret;
}
Exemplo n.º 2
0
void DisplayPin::cancel()
{
	if (!wiz->pbCancel->text().compare("&Retry")) {
		wiz->pbCancel->setText("&Cancel");

		progressBar->setFormat("Touch NFC token in 30 sec");
		progressBar->update();

		lblComment->setText("Input the following PIN to registrar, then push [Next] button.\n");

		if (!MainProcess::writeNfcPassword(MainProcess::getNetworkIndex())) {
			progressBar->setVisible(false);
			MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
			QMessageBox::warning(this, label->text(),
								 "Could not scan NFC token\n");
		} else {
			lblComment->setText(lblComment->text() + "Or touch NFC token to be written device password\n");
			progressBar->setValue(0);
			progressBar->setVisible(true);
			timer->start(100);
		}
	} else {
		MainProcess::cancelScanNfcToken();
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
		wiz->close();
	}
}
Exemplo n.º 3
0
bool DisplayPin::pre_next()
{
	char pin[9];

	wiz->pbCancel->setText("&Cancel");
	wiz->pbBack->setEnabled(true);
	wiz->pbNext->setEnabled(true);
	wiz->pbCancel->setEnabled(true);

	progressBar->setFormat("Touch NFC token in 30 sec");
	progressBar->update();

	MainProcess::generatePIN(pin);
	lblPIN->setText(pin);

	lblComment->setText("Input the following PIN to registrar, then push [Next] button.\n");

	(void)MainProcess::clearWpsPassword();

	MainProcess::connectMonitor(this, SLOT(receiveMsgs()));
	if (!MainProcess::writeNfcPassword(MainProcess::getNetworkIndex())) {
		progressBar->setVisible(false);
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
		QMessageBox::warning(this, label->text(),
							 "Could not scan NFC token\n");
	} else {
		lblComment->setText(lblComment->text() + "Or touch NFC token to be written device password\n");
		progressBar->setValue(0);
		progressBar->setVisible(true);
		timer->start(100);
	}

	return true;
}
Exemplo n.º 4
0
bool WriteNfcConfig::pre_next()
{
	bool ret = false;

	label->setText("NFC Config method");

	wiz->pbCancel->setText("&Cancel");
	wiz->pbBack->setEnabled(true);
	wiz->pbNext->setEnabled(false);
	wiz->pbCancel->setEnabled(true);

	do {
		progressBar->setFormat("Touch NFC token in 30 sec");
		progressBar->update();

		MainProcess::connectMonitor(this, SLOT(receiveMsgs()));
		if (!MainProcess::writeNfcConfig(MainProcess::getNetworkIndex())) {
			progressBar->setVisible(false);
			MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
			QMessageBox::warning(this, label->text(),
								 "Could not scan NFC token\n");
			break;
		} else {
			lblComment->setText("Touch NFC config token to be written network configuration\n");
			progressBar->setValue(0);
			progressBar->setVisible(true);
			timer->start(100);
		}

		ret = true;
	} while (0);

	return ret;
}
Exemplo n.º 5
0
bool WpsPbc::pre_next()
{
	bool ret = false;

	label->setText("PBC method");

	wiz->pbNext->setText("&Start");
	wiz->pbBack->setEnabled(false);
	wiz->pbNext->setEnabled(true);
	wiz->pbCancel->setEnabled(true);
	wiz->pbNext->setFocus();

	do {
		progressBar->setValue(0);
		progressBar->setVisible(false);

		MainProcess::connectMonitor(this, SLOT(receiveMsgs()));

		lblComment->setText("Push-button on registrar, the push [Start] button.\n");

		ret = true;
	} while (0);

	return ret;
}
Exemplo n.º 6
0
bool DisplayPin::post_back()
{
	wiz->pbCancel->setText("&Cancel");
	MainProcess::cancelScanNfcToken();
	MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
	return true;
}
Exemplo n.º 7
0
void InputPin::cancel()
{
	if (!wiz->pbCancel->text().compare("&Retry")) {
		wiz->pbCancel->setText("&Cancel");

		progressBar->setFormat("Touch NFC token in 30 sec");
		progressBar->update();

		if (MainProcess::MODE_REG_REGSTA == MainProcess::getMode())
			lblComment->setText("Input PIN of a target Station, \nthen push [Next] button.\n");
		else
			lblComment->setText("Input PIN of a target Access Point, \nthen push [Next] button.\n");

		if (!MainProcess::readNfcPassword(MainProcess::getNetworkIndex())) {
			progressBar->setVisible(false);
			MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
			QMessageBox::warning(this, label->text(),
								 "Could not scan NFC token\n");
		} else {
			lblComment->setText(lblComment->text() + "Or touch NFC token to be read device password\n");
			progressBar->setValue(0);
			progressBar->setVisible(true);
			timer->start(100);
		}
	} else {
		MainProcess::cancelScanNfcToken();
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));

		if ((MainProcess::MODE_REG_REGSTA != MainProcess::getMode()) ||
			!wiz->pbBack->isEnabled()) {
			wiz->close();
		} else {
			label->setText("Canceled by user indication");
			lblComment->setText("Cancel WPS authentication.\n");
			timer->stop();
			wiz->pbBack->setEnabled(false);
			wiz->pbNext->setEnabled(true);
			wiz->pbNext->setFocus();
			progressBar->setVisible(false);
			label_2->setVisible(false);
			lePin->clear();
			lePin->setVisible(false);
		}
	}
}
Exemplo n.º 8
0
void WriteNfcConfig::cancel()
{
	if (!wiz->pbCancel->text().compare("&Retry")) {
		wiz->pbCancel->setText("&Cancel");

		progressBar->setFormat("Touch NFC token in 30 sec");
		progressBar->update();

		if (!MainProcess::writeNfcConfig(MainProcess::getNetworkIndex())) {
			progressBar->setVisible(false);
			MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
			QMessageBox::warning(this, label->text(),
								 "Could not scan NFC token\n");
			if (MainProcess::MODE_REG_REGSTA != MainProcess::getMode()) {
				MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
				wiz->close();
			} else {
				wiz->pbNext->setEnabled(true);
			}
		} else {
			lblComment->setText("Touch NFC config token to be written network configuration\n");
			progressBar->setValue(0);
			progressBar->setVisible(true);
			timer->start(100);
		}
	} else {
		if (wiz->pbNext->isEnabled() ||
			(MainProcess::MODE_REG_REGSTA != MainProcess::getMode())) {
			MainProcess::cancelScanNfcToken();
			MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
			wiz->close();
		} else {
			label->setText("Canceled by user indication");
			lblComment->setText("Cancel to write network configuration on NFC token.\n");
			timer->stop();
			wiz->pbBack->setEnabled(false);
			wiz->pbNext->setEnabled(true);
			wiz->pbNext->setFocus();
			progressBar->setVisible(false);
		}
	}
}
Exemplo n.º 9
0
bool WriteNfcConfig::post_next()
{
	if (MainProcess::MODE_REG_REGSTA != MainProcess::getMode()) {
		MainProcess::connectNetwork(MainProcess::getNetworkIndex());
	}

	wiz->pbCancel->setText("&Cancel");
	MainProcess::cancelScanNfcToken();
	MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
	return true;
}
Exemplo n.º 10
0
void WpaGui::ping()
{
	char buf[10];
	size_t len;

#ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
	/*
	 * QSocketNotifier cannot be used with Windows named pipes, so use a
	 * timer to check for received messages for now. This could be
	 * optimized be doing something specific to named pipes or Windows
	 * events, but it is not clear what would be the best way of doing that
	 * in Qt.
	 */
	receiveMsgs();
#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */

	if (scanres && !scanres->isVisible()) {
		delete scanres;
		scanres = NULL;
	}

	if (eh && !eh->isVisible()) {
		delete eh;
		eh = NULL;
	}

	if (udr && !udr->isVisible()) {
		delete udr;
		udr = NULL;
	}

	len = sizeof(buf) - 1;
	if (ctrlRequest("PING", buf, &len) < 0) {
		printf("PING failed - trying to reconnect\n");
		if (openCtrlConnection(ctrl_iface) >= 0) {
			printf("Reconnected successfully\n");
			pingsToStatusUpdate = 0;
		}
	}

	pingsToStatusUpdate--;
	if (pingsToStatusUpdate <= 0) {
		updateStatus();
		updateNetworks();
	}

#ifndef CONFIG_CTRL_IFACE_NAMED_PIPE
	/* Use less frequent pings and status updates when the main window is
	 * hidden (running in taskbar). */
	int interval = isHidden() ? 5000 : 1000;
	if (timer->interval() != interval)
		timer->setInterval(interval);
#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
}
Exemplo n.º 11
0
bool InputPin::pre_next()
{
	wiz->pbCancel->setText("&Cancel");
	wiz->pbBack->setEnabled(true);
	wiz->pbNext->setEnabled(true);
	wiz->pbCancel->setEnabled(true);
	lePin->setFocus();

	progressBar->setFormat("Touch NFC token in 30 sec");
	progressBar->update();

	label->setText("PIN method");
	label_2->setVisible(true);
	lePin->clear();
	lePin->setVisible(true);
	lePin->setEnabled(true);

	if (MainProcess::MODE_REG_REGSTA == MainProcess::getMode())
		lblComment->setText("Input PIN of a target Station, \nthen push [Next] button.\n");
	else
		lblComment->setText("Input PIN of a target Access Point, \nthen push [Next] button.\n");

	MainProcess::connectMonitor(this, SLOT(receiveMsgs()));
	if (!MainProcess::readNfcPassword(MainProcess::getNetworkIndex())) {
		progressBar->setVisible(false);
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));
		QMessageBox::warning(this, label->text(),
							 "Could not scan NFC token\n");
	} else {
		lblComment->setText(lblComment->text() + "Or touch NFC token to be read device password\n");
		progressBar->setValue(0);
		progressBar->setVisible(true);
		timer->start(100);
	}

	return true;
}
Exemplo n.º 12
0
void WpsPbc::cancel()
{
	if (timer->isActive()) {
		timer->stop();
		MainProcess::stopPbc();
		wiz->pbCancel->setText("&Finish");
		wiz->pbNext->setText("&Next");
		wiz->pbNext->setEnabled(false);
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));

		label->setText("Canceled by user indication");
		progressBar->setVisible(false);
		lblComment->setText("Cancel WPS authentication.\n");
	} else {
		wiz->close();
	}
}
Exemplo n.º 13
0
bool DisplayPin::post_next()
{
	bool ret = false;
	int index;


	do {
		index = MainProcess::getNetworkIndex();

		if (!MainProcess::setNetworkParam(index, "key_mgmt", "IEEE8021X", false)) {
			QMessageBox::warning(this, label->text(),
								 "Could not set parameter : key_mgmt.\n");
			break;
		}

		if (!MainProcess::setNetworkParam(index, "eap", "WPS", false)) {
			QMessageBox::warning(this, label->text(),
								 "Could not set parameter : eap.\n");
			break;
		}

		if (!MainProcess::setNetworkParam(index, "identity", WPS_IDENTITY_ENROLLEE, true)) {
			QMessageBox::warning(this, label->text(),
								 "Could not set parameter : eap.\n");
			break;
		}

		if (!lblPIN->text().compare("Written on NFC Token.")) {
			MainProcess::setNetworkParam(index, "password", "", true);
		} else {
			if (!MainProcess::setNetworkParam(index, "password", 
											 (char *)((const char *)lblPIN->text().toAscii()), true)) {
				QMessageBox::warning(this, label->text(),
									 "Could not set parameter : password.\n");
			}
		}

		wiz->pbCancel->setText("&Cancel");
		MainProcess::cancelScanNfcToken();
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));

		ret = true;
	} while (0);

	return ret;
}
Exemplo n.º 14
0
bool InputPin::post_next()
{
	bool ret = false;
	do {
		if ((MainProcess::MODE_REG_REGSTA == MainProcess::getMode()) &&
			!lePin->isVisible()) {
			ret = true;
			break;
		}

		if (lePin->isEnabled()) {
			if (!lePin->text().length()) {
				lePin->setFocus();
				if (MainProcess::MODE_REG_REGSTA == MainProcess::getMode())
					QMessageBox::warning(this, label->text(),
										 "Should input PIN of a target Station.\n");
				else
					QMessageBox::warning(this, label->text(),
										 "Should input PIN of a target Access Point.\n");
				break;
			}

			if (8 == lePin->text().length()) {
				if (!MainProcess::validatePIN(lePin->text().toAscii())) {
					if (QMessageBox::No ==
						QMessageBox::question(this, label->text(),
								 "PIN has invalidate checksum.\n"
								 "Do you really use this PIN?\n",
								 QMessageBox::Yes|QMessageBox::No)) {
						lePin->setFocus();
						break;
					}
				}
			}
		}

		if (MainProcess::isEnabledUpnp()) {
			if (lePin->isEnabled()) {
				if (!MainProcess::setWpsPassword(lePin->text().toAscii())) {
					QMessageBox::warning(this, label->text(),
										 "Could not set WPS password.\n");
					break;
				}
			}

			if (MainProcess::MODE_REG_CONFAP == MainProcess::getMode()) {
				if (!MainProcess::sendUpnpGetDevInfo(MainProcess::getControlUrl())) {
					QMessageBox::warning(this, label->text(),
										 "Could not send GetDeviceInfo thru UPnP.\n");
					break;
				}
			} else if (MainProcess::MODE_REG_REGSTA == MainProcess::getMode()) {
				if (!MainProcess::setWpsConfiguration(MainProcess::getNetworkIndex())) {
					QMessageBox::warning(this, label->text(),
										 "Could not set WPS network configuration.\n");
					break;
				}

				if (!MainProcess::sendSelectedRegistrar(MainProcess::getControlUrl(), true)) {
					QMessageBox::warning(this, label->text(),
										 "Could not send SelectedRegistrar thru UPnP.\n");
					break;
				}
			}
		} else if (0 <= MainProcess::getNetworkIndex()) {
			int index = MainProcess::getNetworkIndex();
			if (!MainProcess::setNetworkParam(index, "key_mgmt", "IEEE8021X", false)) {
				QMessageBox::warning(this, label->text(),
									 "Could not set parameter : key_mgmt.\n");
				break;
			}

			if (!MainProcess::setNetworkParam(index, "eap", "WPS", false)) {
				QMessageBox::warning(this, label->text(),
									 "Could not set parameter : eap.\n");
				break;
			}

			if (!MainProcess::setNetworkParam(index, "identity", WPS_IDENTITY_REGISTRAR, true)) {
				QMessageBox::warning(this, label->text(),
									 "Could not set parameter : eap.\n");
				break;
			}

			if (!lePin->isEnabled()) {
				MainProcess::setNetworkParam(index, "password", "", true);
			} else {
				if (!MainProcess::setNetworkParam(index, "password", 
												 (char *)((const char *)lePin->text().toAscii()), true)) {
					QMessageBox::warning(this, label->text(),
										 "Could not set parameter : password.\n");
					break;
				}
			}
		}

		wiz->pbCancel->setText("&Cancel");
		MainProcess::cancelScanNfcToken();
		MainProcess::disconnectMonitor(this, SLOT(receiveMsgs()));

		ret = true;
	} while (0);

	return ret;
}