some fixes and checking wifi password

This commit is contained in:
Szybet 2022-08-20 21:21:50 +02:00
parent e310544fb5
commit 6e9e5176c5
2 changed files with 73 additions and 26 deletions

View file

@ -203,6 +203,9 @@ void wifiDialog::launchRefresh() {
string_writeconfig("/opt/ibxd", "list_wifi_networks\n"); string_writeconfig("/opt/ibxd", "list_wifi_networks\n");
QTimer::singleShot(0, this, SLOT(refreshWait())); QTimer::singleShot(0, this, SLOT(refreshWait()));
} }
else {
log("Scan is already in progress", className);
}
} }
void wifiDialog::refreshWait() { void wifiDialog::refreshWait() {
@ -374,28 +377,40 @@ void wifiDialog::refreshNetworksList() {
void wifiDialog::on_Wificheckbox_stateChanged(int arg1) void wifiDialog::on_Wificheckbox_stateChanged(int arg1)
{ {
connectedNetworkDataParentSetted = false; if(ignoreCheckboxCall == false) {
log("wifi dialog clicked: " + QString::number(arg1), className); connectedNetworkDataParentSetted = false;
if(wifiButtonEnabled == true) { log("wifi dialog clicked: " + QString::number(arg1), className);
if(arg1 == 2) { if(wifiButtonEnabled == true) {
log("turning wifi on", className); if(arg1 == 2) {
// the watcher will scan wifi log("turning wifi on", className);
forceRefresh = true; // the watcher will scan wifi
QTimer::singleShot(0, this, SLOT(turnOnWifi())); forceRefresh = true;
ui->stopBtn->setStyleSheet("background-color:white;"); QTimer::singleShot(0, this, SLOT(turnOnWifi()));
ui->stopBtn->setEnabled(true); ui->stopBtn->setStyleSheet("background-color:white;");
} else { ui->stopBtn->setEnabled(true);
log("turning wifi off", className); } else {
QTimer::singleShot(0, this, SLOT(turnOffWifi())); log("turning wifi off", className);
ui->stopBtn->setStyleSheet("background-color:grey;"); QTimer::singleShot(0, this, SLOT(turnOffWifi()));
ui->stopBtn->setEnabled(false); ui->stopBtn->setStyleSheet("background-color:grey;");
ui->stopBtn->setEnabled(false);
}
emit killNetworkWidgets();
}
if(wifiButtonEnabled == false){
wifiButtonEnabled = true;
}
}
else {
ignoreCheckboxCall = true;
if(checkWifiState() != global::wifi::WifiState::Disabled) {
emit killNetworkWidgets();
forceRefresh = true;
}
else {
emit killNetworkWidgets();
} }
emit killNetworkWidgets();
} }
if(wifiButtonEnabled == false){
wifiButtonEnabled = true;
}
} }
void wifiDialog::turnOnWifi() { void wifiDialog::turnOnWifi() {
@ -439,6 +454,7 @@ prepare_changing_wifi.sh - Kills everything, prepares to changing network
smarter_time_sync.sh - Synces time smarter_time_sync.sh - Synces time
toggle.sh - Turns on / off toggle.sh - Turns on / off
list_networks.bin - Well lists networks list_networks.bin - Well lists networks
check_wifi_password.sh - Checks wifi password
theWatcher() first watches at processes that could kill other ones theWatcher() first watches at processes that could kill other ones
*/ */
@ -449,6 +465,7 @@ void wifiDialog::theWatcher() {
if(killing == true) { if(killing == true) {
setStatusText("Changing wifi state"); setStatusText("Changing wifi state");
log("toggle.sh is active", className); log("toggle.sh is active", className);
isToggleRunning = true;
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher())); QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
return void(); return void();
} }
@ -483,6 +500,23 @@ void wifiDialog::theWatcher() {
return void(); return void();
} }
bool dhcp = checkProcessName("get_dhcp.sh");
if(dhcp == true) {
forceRefresh = true;
setStatusText("Getting IP address");
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
return void();
}
bool passwordCheck = checkProcessName("check_wifi_password.sh");
if(passwordCheck == true) {
forceRefresh = true;
setStatusText("Checking wi-fi password");
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
return void();
}
bool time = checkProcessName("smarter_time_sync.sh"); bool time = checkProcessName("smarter_time_sync.sh");
if(time == true) { if(time == true) {
forceRefresh = true; forceRefresh = true;
@ -491,13 +525,6 @@ void wifiDialog::theWatcher() {
return void(); return void();
} }
bool dhcp = checkProcessName("get_dhcp.sh");
if(dhcp == true) {
forceRefresh = true;
setStatusText("Getting IP address");
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
return void();
}
bool connecting = checkProcessName("connection_manager.sh"); bool connecting = checkProcessName("connection_manager.sh");
if(connecting == true) { if(connecting == true) {
@ -522,6 +549,23 @@ void wifiDialog::theWatcher() {
unlockCheckbox = false; unlockCheckbox = false;
} }
if(isToggleRunning == true) {
isToggleRunning = false;
// To make sure the checkbox is in the right state
if(checkWifiState() == global::wifi::WifiState::Disabled) {
if(ui->Wificheckbox->isChecked() == true) {
ignoreCheckboxCall = true;
ui->Wificheckbox->setChecked(false);
}
}
else {
if(ui->Wificheckbox->isChecked() == false) {
ignoreCheckboxCall = true;
ui->Wificheckbox->setChecked(true);
}
}
}
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher())); QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
} }

View file

@ -40,6 +40,9 @@ private:
bool unlockCheckbox = false; bool unlockCheckbox = false;
bool scanInProgress = false; bool scanInProgress = false;
bool isToggleRunning = false;
bool ignoreCheckboxCall = false;
public slots: public slots:
void launchRefresh(); void launchRefresh();
void refreshNetworksList(); void refreshNetworksList();