void RouterKeygen::calc(QString ssid, QString mac) {
	if (calculator != NULL) {
		return; //ignore while a calculator is still running
	}
	if (router != NULL)
		delete router;
	if (ssid == "")
		return;
	if (mac.length() < 17) {
		mac = "";
		if (mac.length() != 5)
			ui->statusBar->showMessage(tr("Invalid MAC. It will not be used."));
	}

	router = matcher.getKeygen(ssid, mac, 0, "");
	if (!router) {
		ui->statusBar->showMessage(
				tr("Unsupported network. Check the MAC address and the SSID."));
		return;
	}
	ui->passwordsList->clear();
	setLoadingAnimation(tr("Calculating keys. This can take a while."));
	this->calculator = new KeygenThread(router);
	connect(this->calculator, SIGNAL( finished() ), this, SLOT( getResults() ));
	ui->calculateButton->setEnabled(false);
	ui->refreshScan->setEnabled(false);
	this->calculator->start();
}
void  RouterKeygen::checkUpdates(){
    QNetworkAccessManager* mNetworkManager = new QNetworkAccessManager(this);
    QObject::connect(mNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onNetworkReply(QNetworkReply*)));
    if ( !automaticUpdateCheck ){
        enableUI(false);
        setLoadingAnimation(tr("Checking for updates"));
    }
    QUrl url("https://raw.github.com/routerkeygen/routerkeygenPC/master/routerkeygen_version.json");
    mNetworkManager->get(QNetworkRequest(url));
}
void RouterKeygen::calc(QScanResult * wifi) {
    if (calculator != NULL) {
        return; //ignore while a calculator is still running
    }
    if (wifi->getSupportState() == Keygen::UNSUPPORTED) {
        ui->statusBar->showMessage(
                tr("Unsupported network. Check the MAC address and the SSID."));
        return;
    }
    ui->passwordsList->clear();
    setLoadingAnimation(tr("Calculating keys. This can take a while."));
    this->calculator = new KeygenThread(wifi->getKeygens());
    connect(this->calculator, SIGNAL( finished() ), this, SLOT( getResults() ));
    enableUI(false);
    this->calculator->start();
}
void RouterKeygen::refreshNetworks() {
    enableUI(false);
    setLoadingAnimation(tr("Scanning the network"));
    wifiManager->startScan();
}
void RouterKeygen::refreshNetworks() {
	ui->refreshScan->setEnabled(false);
	ui->calculateButton->setEnabled(false);
	setLoadingAnimation(tr("Scanning the network"));
	wifiManager->startScan();
}