mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Review
This commit is contained in:
parent
94257927f3
commit
5f9cff5a84
13 changed files with 210 additions and 252 deletions
|
@ -166,13 +166,12 @@ namespace global {
|
|||
inline QString bookPath;
|
||||
}
|
||||
namespace wifi {
|
||||
// This is the correct way to do this.
|
||||
enum class WifiState
|
||||
enum class wifiState
|
||||
{
|
||||
Configured,
|
||||
Enabled,
|
||||
Disabled,
|
||||
Unknown, // to not confuse lastWifiState
|
||||
configured,
|
||||
enabled,
|
||||
disabled,
|
||||
unknown, // To not confuse lastWifiState
|
||||
};
|
||||
inline bool isConnected;
|
||||
class wifiNetworkData {
|
||||
|
@ -1069,36 +1068,35 @@ namespace {
|
|||
return 2;
|
||||
}
|
||||
}
|
||||
global::wifi::WifiState checkWifiState() {
|
||||
global::wifi::wifiState checkWifiState() {
|
||||
QProcess *wifiStateProcess = new QProcess();
|
||||
// Important to remember thats its in chroot...
|
||||
// What can be run in the chroot, should be run here. ibxd is a bit a mess
|
||||
QString path = "/external_root/usr/local/bin/wifi/wifi_status.sh";
|
||||
QStringList args;
|
||||
wifiStateProcess->start(path, args);
|
||||
wifiStateProcess->waitForFinished();
|
||||
wifiStateProcess->deleteLater();
|
||||
|
||||
QString currentWifiState;
|
||||
if(QFile("/run/wifi_status").exists() == true) {
|
||||
currentWifiState = readFile("/run/wifi_status");
|
||||
} else {
|
||||
log("/run/wifi_status doesnt exist");
|
||||
log("/run/wifi_status doesn't exist", "functions");
|
||||
}
|
||||
if (currentWifiState.contains("configured") == true) {
|
||||
global::wifi::isConnected = true;
|
||||
return global::wifi::WifiState::Configured;
|
||||
return global::wifi::wifiState::configured;
|
||||
}
|
||||
else if (currentWifiState.contains("enabled") == true) {
|
||||
global::wifi::isConnected = false;
|
||||
return global::wifi::WifiState::Enabled;
|
||||
return global::wifi::wifiState::enabled;
|
||||
}
|
||||
else if (currentWifiState.contains("disabled") == true) {
|
||||
global::wifi::isConnected = false;
|
||||
return global::wifi::WifiState::Disabled;
|
||||
return global::wifi::wifiState::disabled;
|
||||
} else {
|
||||
global::wifi::isConnected = false;
|
||||
log("Critical error, checkWifiState()", "functions.h");
|
||||
return global::wifi::WifiState::Unknown;
|
||||
QString function = __func__; log(function + ": Critical error", "functions");
|
||||
return global::wifi::wifiState::unknown;
|
||||
}
|
||||
}
|
||||
int testPing() {
|
||||
|
|
|
@ -753,35 +753,35 @@ void MainWindow::setupSearchDialog() {
|
|||
|
||||
void MainWindow::updateWifiIcon() {
|
||||
/* Usage:
|
||||
* Mode 0 (looping it) is handled in mainwindow()
|
||||
* Mode 0 (looping it) is handled in MainWindow
|
||||
*/
|
||||
|
||||
global::wifi::WifiState currentWifiState = checkWifiState();
|
||||
global::wifi::wifiState currentWifiState = checkWifiState();
|
||||
|
||||
// Its executing only in Enabled mode, which is a mode between connected and disabled so don't worry about performance
|
||||
if(isConnecting == false and isReconecting == false) {
|
||||
if(currentWifiState == global::wifi::WifiState::Enabled) {
|
||||
// It's executing only in enabled mode, which is a mode between connected and disabled, so don't worry about performance
|
||||
if(isConnecting == false and isReconnecting == false) {
|
||||
if(currentWifiState == global::wifi::wifiState::enabled) {
|
||||
if(checkProcessName("connection_manager.sh") == true) {
|
||||
isConnecting = true;
|
||||
}
|
||||
else if(checkProcessName("connect_to_network.sh") == true){
|
||||
isConnecting = true;
|
||||
isReconecting = true;
|
||||
isReconnecting = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ms can make diffrence so:
|
||||
// ms can make a difference, so:
|
||||
currentWifiState = checkWifiState();
|
||||
|
||||
if(lastWifiState != currentWifiState) {
|
||||
if(currentWifiState == global::wifi::WifiState::Disabled) {
|
||||
if(currentWifiState == global::wifi::wifiState::disabled) {
|
||||
if(isConnecting == true) {
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped") == false) {
|
||||
QString wifiName = readFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").replace("\n", "");
|
||||
if(isReconecting == true) {
|
||||
showToast("Failed to reconnect to " + wifiName);
|
||||
isReconecting = false;
|
||||
if(isReconnecting == true) {
|
||||
showToast("Failed to reconnnect to " + wifiName);
|
||||
isReconnecting = false;
|
||||
}
|
||||
else {
|
||||
showToast("Failed to connect to " + wifiName);
|
||||
|
@ -794,22 +794,22 @@ void MainWindow::updateWifiIcon() {
|
|||
QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped").remove();
|
||||
}
|
||||
}
|
||||
lastWifiState = global::wifi::WifiState::Disabled;
|
||||
lastWifiState = global::wifi::wifiState::disabled;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
if(currentWifiState == global::wifi::WifiState::Enabled) {
|
||||
lastWifiState = global::wifi::WifiState::Enabled;
|
||||
if(currentWifiState == global::wifi::wifiState::enabled) {
|
||||
lastWifiState = global::wifi::wifiState::enabled;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
if(currentWifiState == global::wifi::WifiState::Configured) {
|
||||
if(currentWifiState == global::wifi::wifiState::configured) {
|
||||
if(isConnecting == true) {
|
||||
setDefaultWorkDir();
|
||||
QString wifiName = readFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").replace("\n", "");
|
||||
if(isReconecting == true) {
|
||||
if(isReconnecting == true) {
|
||||
showToast("Reconnected successfully to " + wifiName);
|
||||
isReconecting = false;
|
||||
isReconnecting = false;
|
||||
}
|
||||
else {
|
||||
showToast("Connected successfully to " + wifiName);
|
||||
|
@ -817,13 +817,11 @@ void MainWindow::updateWifiIcon() {
|
|||
isConnecting = false;
|
||||
QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped").remove();
|
||||
}
|
||||
lastWifiState = global::wifi::WifiState::Configured;
|
||||
ui->wifiBtn->setIcon(QIcon("://resources/wifi-100.png"));
|
||||
lastWifiState = global::wifi::wifiState::configured;
|
||||
ui->wifiBtn->setIcon(QIcon(":/resources/wifi-100.png"));
|
||||
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::updateWifiAble() {
|
||||
|
@ -849,7 +847,7 @@ void MainWindow::showToast(QString messageToDisplay) {
|
|||
connect(toastWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
|
||||
toastWindow->show();
|
||||
|
||||
// I will soon manage the update thing in a more propper way somewhere else... ~ Szybet
|
||||
// I will soon manage the update thing in a more proper way somewhere else... ~ Szybet
|
||||
if(messageToDisplay.contains("onnected successfully") == true) {
|
||||
// Give the toast some time to vanish away, then launch OTA updater
|
||||
QTimer::singleShot(5000, this, SLOT(launchOtaUpdater()));
|
||||
|
|
|
@ -52,9 +52,9 @@ public:
|
|||
bool reboot_after_update = false;
|
||||
bool resetFullWindowException;
|
||||
|
||||
global::wifi::WifiState lastWifiState = global::wifi::WifiState::Unknown;
|
||||
global::wifi::wifiState lastWifiState = global::wifi::wifiState::unknown;
|
||||
bool isConnecting = false;
|
||||
bool isReconecting = false;
|
||||
bool isReconnecting = false;
|
||||
|
||||
int timerTime = 0;
|
||||
QString relative_path;
|
||||
|
|
|
@ -41,8 +41,6 @@ int main(int argc, char *argv[])
|
|||
global::logger::status = true;
|
||||
}
|
||||
}
|
||||
// Szybet testing
|
||||
global::logger::status = true;
|
||||
|
||||
global::deviceID = readFile("/opt/inkbox_device");
|
||||
log("Running on device " + global::deviceID, "main", true);
|
||||
|
|
|
@ -18,7 +18,7 @@ connectiondialog::connectiondialog(QWidget *parent) :
|
|||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
stylesheetFile.close();
|
||||
|
||||
ui->CancelBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->cancelBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->connectBtn->setStyleSheet("font-size: 9pt");
|
||||
ui->showPasswordBtn->setStyleSheet("font-size: 9pt");
|
||||
|
||||
|
@ -35,7 +35,7 @@ connectiondialog::~connectiondialog()
|
|||
}
|
||||
|
||||
void connectiondialog::applyVariables() {
|
||||
// Here for some devices it will be propably needed to limit the size. the nia is fine
|
||||
// Here, for some devices it will be propably needed to limit the size
|
||||
ui->nameLabel->setText(connectedNetworkData.name);
|
||||
ui->macLabel->setText(connectedNetworkData.mac);
|
||||
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
|
||||
|
@ -62,8 +62,8 @@ void connectiondialog::applyVariables() {
|
|||
}
|
||||
QString password = searchDatabase(connectedNetworkData.name);
|
||||
if(password.isEmpty() == false) {
|
||||
log("found password: " + password, className);
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/show.png"));
|
||||
log("Found password: " + password, className);
|
||||
ui->showPasswordBtn->setIcon(QIcon(":/resources/show.png"));
|
||||
showedPassword = false;
|
||||
savedPassword = password;
|
||||
|
||||
|
@ -89,16 +89,15 @@ QString connectiondialog::searchDatabase(QString key) {
|
|||
for(QJsonValueRef refJsonObject: jsonArray) {
|
||||
QJsonObject jsonMainObject = refJsonObject.toObject();
|
||||
QString searchedName = jsonMainObject.keys().first().toUtf8();
|
||||
log("Found in database: " + searchedName, className);
|
||||
log("Found in database: '" + searchedName + "'", className);
|
||||
if(searchedName == key) {
|
||||
QString returnedPassword = jsonMainObject.value(key).toString();
|
||||
log("Searched name " + searchedName + " matched " + key + " and the password is: " + returnedPassword, className);
|
||||
log("Searched name '" + searchedName + "' matched '" + key + "' and the password is: '" + returnedPassword + "'", className);
|
||||
return returnedPassword;
|
||||
}
|
||||
else {
|
||||
log("Searched name " + searchedName + " Doesn't match " + key, className);
|
||||
log("Searched name '" + searchedName + "' doesn't match " + key + "'", className);
|
||||
}
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -122,7 +121,7 @@ void connectiondialog::writeToDatabase(QString name, QString password) {
|
|||
QJsonValue newValue;
|
||||
|
||||
// https://stackoverflow.com/questions/26804660/how-to-initialize-qjsonobject-from-qstring
|
||||
// I hoped this will be easier
|
||||
// I hoped this would be easier
|
||||
QJsonObject newObject = QJsonDocument::fromJson(QString("{\"" + name + "\" : \"" + password + "\" }").toUtf8()).object();
|
||||
jsonArray.append(newObject);
|
||||
|
||||
|
@ -154,7 +153,7 @@ void connectiondialog::removeFromDatabase(QString name) {
|
|||
for(QJsonValueRef refJsonObject: jsonArray) {
|
||||
QJsonObject jsonMainObject = refJsonObject.toObject();
|
||||
QString searchedName = jsonMainObject.keys().first().toUtf8();
|
||||
log("Found in database: " + searchedName, className);
|
||||
log("Found in database: '" + searchedName + "'", className);
|
||||
if(searchedName == name) {
|
||||
remove = true;
|
||||
}
|
||||
|
@ -175,12 +174,12 @@ void connectiondialog::removeFromDatabase(QString name) {
|
|||
passwordDatabase.close();
|
||||
}
|
||||
else {
|
||||
log("ERROR: tryied to remove from database, but couldn't find key", className);
|
||||
log("ERROR: tried to remove from database, but couldn't find key", className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void connectiondialog::on_CancelBtn_clicked()
|
||||
void connectiondialog::on_cancelBtn_clicked()
|
||||
{
|
||||
this->deleteLater();
|
||||
this->close();
|
||||
|
@ -193,7 +192,7 @@ void connectiondialog::on_passwordTextEdit_selectionChanged()
|
|||
|
||||
void connectiondialog::on_passwordTextEdit_cursorPositionChanged(int oldpos, int newpos)
|
||||
{
|
||||
log("Detected click on text edit", className);
|
||||
log("Detected click on text edit widget", className);
|
||||
if(cursorPositionIgnore == true) {
|
||||
if(newpos != 0) {
|
||||
if(showedPassword == true) {
|
||||
|
@ -212,10 +211,10 @@ void connectiondialog::on_passwordTextEdit_cursorPositionChanged(int oldpos, int
|
|||
global::keyboard::keyboardDialog = false;
|
||||
global::keyboard::wifiPassphraseDialog = false;
|
||||
if(global::keyboard::keyboardText.isEmpty() == false) {
|
||||
// A bit hacky: avoid summoning the keyboard back when the text is changing ( and the cursor too ) showedPassword shouldnt be used for this, but it works and adding another bool would start being messy
|
||||
// A bit hacky: avoid summoning the keyboard back when the text is changing (and the cursor too) showedPassword shouldn't be used for this, but it works and adding another boolean would start being messy
|
||||
showedPassword = false;
|
||||
ui->passwordTextEdit->setText(global::keyboard::keyboardText);
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/hide.png"));
|
||||
ui->showPasswordBtn->setIcon(QIcon(":/resources/hide.png"));
|
||||
ui->showPasswordBtn->show();
|
||||
showedPassword = true;
|
||||
savedPassword = global::keyboard::keyboardText;
|
||||
|
@ -224,7 +223,7 @@ void connectiondialog::on_passwordTextEdit_cursorPositionChanged(int oldpos, int
|
|||
global::keyboard::keyboardText = "";
|
||||
}
|
||||
else {
|
||||
log("Password is not saved so ignoring text edit call", className);
|
||||
log("Password is not saved; ignoring text edit call", className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,13 +240,13 @@ void connectiondialog::showToastSlot(QString message) {
|
|||
void connectiondialog::on_showPasswordBtn_clicked()
|
||||
{
|
||||
if(showedPassword == false) {
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/hide.png"));
|
||||
ui->showPasswordBtn->setIcon(QIcon(":/resources/hide.png"));
|
||||
ui->passwordTextEdit->setText(savedPassword);
|
||||
showedPassword = true;
|
||||
}
|
||||
else {
|
||||
showedPassword = false;
|
||||
ui->showPasswordBtn->setIcon(QIcon("://resources/show.png"));
|
||||
ui->showPasswordBtn->setIcon(QIcon(":/resources/show.png"));
|
||||
ui->passwordTextEdit->setText("********");
|
||||
}
|
||||
}
|
||||
|
@ -275,26 +274,26 @@ void connectiondialog::on_connectBtn_clicked()
|
|||
}
|
||||
passwordForReconnecting = finalPassword;
|
||||
|
||||
ui->CancelBtn->setEnabled(false);
|
||||
if(checkWifiState() == global::wifi::WifiState::Configured) {
|
||||
ui->cancelBtn->setEnabled(false);
|
||||
if(checkWifiState() == global::wifi::wifiState::configured) {
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
}
|
||||
string_writeconfig("/run/wifi_network_essid", connectedNetworkData.name.toStdString());
|
||||
string_writeconfig("/run/wifi_network_passphrase", finalPassword.toStdString());
|
||||
writeFile("/run/wifi_network_essid", connectedNetworkData.name);
|
||||
writeFile("/run/wifi_network_passphrase", finalPassword);
|
||||
finalConnectWait();
|
||||
}
|
||||
|
||||
void connectiondialog::finalConnectWait() {
|
||||
if(checkIfWifiBussy() == true) {
|
||||
if(checkIfWifiBusy() == true) {
|
||||
// To be sure
|
||||
if(waitTry == 10) {
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
}
|
||||
// Max 10s to wait for everything to shut down
|
||||
// Wait for everything to shut down; 10 seconds timeout
|
||||
if(waitTry == 20) {
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
emit showToastSignal("Failed to stop other wifi processes");
|
||||
ui->CancelBtn->setEnabled(true);
|
||||
emit showToastSignal("Failed to stop other Wi-Fi processes");
|
||||
ui->cancelBtn->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
QTimer::singleShot(500, this, SLOT(finalConnectWait()));
|
||||
|
@ -304,8 +303,8 @@ void connectiondialog::finalConnectWait() {
|
|||
else {
|
||||
string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n");
|
||||
|
||||
// This will be deleted later in mainwindow icon updater if it failed. Its also deleted in stop wifi script
|
||||
log("Writing to config dir with connection data", className);
|
||||
// This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script
|
||||
log("Writing to config directory with connection information data", className);
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString());
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passwordForReconnecting.toStdString());
|
||||
|
||||
|
@ -314,10 +313,8 @@ void connectiondialog::finalConnectWait() {
|
|||
}
|
||||
}
|
||||
|
||||
bool connectiondialog::checkIfWifiBussy() {
|
||||
if(checkProcessName("connect_to_network.sh") == true or
|
||||
checkProcessName("connection_manager.sh") == true or
|
||||
checkProcessName("prepare_changing_wifi.sh") == true) {
|
||||
bool connectiondialog::checkIfWifiBusy() {
|
||||
if(checkProcessName("connect_to_network.sh") == true or checkProcessName("connection_manager.sh") == true or checkProcessName("prepare_changing_wifi.sh") == true) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -30,25 +30,20 @@ public slots:
|
|||
void refreshScreenSlot();
|
||||
|
||||
private slots:
|
||||
// I know im opening / loading json many times, its maybe not efficient but:
|
||||
// 1. Its modular
|
||||
// We are opening/loading the JSON database many times, it might not be efficient, but:
|
||||
// 1. It's modular
|
||||
// 2. Those operations are rare
|
||||
QString searchDatabase(QString key);
|
||||
void writeToDatabase(QString name, QString password);
|
||||
void removeFromDatabase(QString name);
|
||||
|
||||
|
||||
void finalConnectWait();
|
||||
bool checkIfWifiBussy();
|
||||
|
||||
void on_CancelBtn_clicked();
|
||||
bool checkIfWifiBusy();
|
||||
|
||||
void on_cancelBtn_clicked();
|
||||
void on_passwordTextEdit_selectionChanged();
|
||||
|
||||
void on_passwordTextEdit_cursorPositionChanged(int arg1, int arg2);
|
||||
|
||||
void on_showPasswordBtn_clicked();
|
||||
|
||||
void on_connectBtn_clicked();
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="CancelBtn">
|
||||
<widget class="QPushButton" name="cancelBtn">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
|
|
|
@ -17,10 +17,7 @@ network::network(QWidget *parent) :
|
|||
// Buttons
|
||||
ui->encryptionIcon->setProperty("type", "borderless");
|
||||
ui->encryptionIcon->setStyleSheet("QPushButton[type='borderless']:pressed { background: white; color: white; border: none; }");
|
||||
|
||||
ui->enterButton->setProperty("type", "borderless");
|
||||
|
||||
ui->enterButton->setFixedWidth(40);
|
||||
}
|
||||
|
||||
network::~network()
|
||||
|
@ -36,20 +33,19 @@ void network::applyVariables() {
|
|||
}
|
||||
ui->signalStrengthLabel->setText(QString::number(mainData.signal) + percent);
|
||||
|
||||
// Limit name size, maybe device specific
|
||||
QString cuttedSingleData = mainData.name;
|
||||
if(cuttedSingleData.count() > 27)
|
||||
{
|
||||
cuttedSingleData = cuttedSingleData.remove(24, cuttedSingleData.count() - 24);
|
||||
cuttedSingleData.append("...");
|
||||
// Limit name size
|
||||
QString cutSingleData = mainData.name;
|
||||
if(cutSingleData.count() > 27) {
|
||||
cutSingleData = cutSingleData.remove(24, cutSingleData.count() - 24);
|
||||
cutSingleData.append("...");
|
||||
}
|
||||
ui->nameLabel->setText(cuttedSingleData);
|
||||
ui->nameLabel->setText(cutSingleData);
|
||||
|
||||
if(mainData.encryption == true) {
|
||||
ui->encryptionIcon->setIcon(QIcon("://resources/lock.png"));
|
||||
ui->encryptionIcon->setIcon(QIcon(":/resources/lock.png"));
|
||||
}
|
||||
else {
|
||||
ui->encryptionIcon->setIcon(QIcon("://resources/public.png"));
|
||||
ui->encryptionIcon->setIcon(QIcon(":/resources/public.png"));
|
||||
}
|
||||
|
||||
if(currentlyConnectedNetwork == mainData.name) {
|
||||
|
@ -59,25 +55,24 @@ void network::applyVariables() {
|
|||
ui->encryptionIcon->setStyleSheet("background-color:grey;");
|
||||
ui->enterButton->setStyleSheet("background-color:grey;");
|
||||
|
||||
// Some stylesheet magician could make it work that it cant be clicked
|
||||
ui->encryptionIcon->setStyleSheet("QPushButton {background-color: grey; border: none}; QPushButton[type='borderless']:pressed { background: grey; color: grey; border: none; }");
|
||||
|
||||
ui->enterButton->setStyleSheet("QPushButton {background-color: grey; border: none}; QPushButton[type='borderless']:pressed { background: grey; color: grey; border: none; }");
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ui->frame->setStyleSheet(".QFrame{background-color: white; border: 3px solid black; border-radius: 10px;}");
|
||||
}
|
||||
}
|
||||
|
||||
void network::on_enterButton_clicked()
|
||||
{
|
||||
connectiondialog* newConnectionDiallog = new connectiondialog;
|
||||
newConnectionDiallog->connectedNetworkData = mainData;
|
||||
newConnectionDiallog->currentlyConnectedNetworkName = currentlyConnectedNetwork;
|
||||
newConnectionDiallog->applyVariables();
|
||||
connect(newConnectionDiallog, &connectiondialog::showToastSignal, this, &network::showToastSlot);
|
||||
connect(newConnectionDiallog, &connectiondialog::refreshScreenSignal, this, &network::refreshScreenSlot);
|
||||
newConnectionDiallog->exec();
|
||||
connectiondialog* newConnectionDialog = new connectiondialog;
|
||||
newConnectionDialog->connectedNetworkData = mainData;
|
||||
newConnectionDialog->currentlyConnectedNetworkName = currentlyConnectedNetwork;
|
||||
newConnectionDialog->applyVariables();
|
||||
connect(newConnectionDialog, &connectiondialog::showToastSignal, this, &network::showToastSlot);
|
||||
connect(newConnectionDialog, &connectiondialog::refreshScreenSignal, this, &network::refreshScreenSlot);
|
||||
newConnectionDialog->exec();
|
||||
}
|
||||
|
||||
void network::closeWrapper() {
|
||||
|
|
|
@ -28,15 +28,9 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
ui->stopBtn->setIcon(QIcon(":/resources/stop.png"));
|
||||
ui->logBtn->setIcon(QIcon(":/resources/file-text.png"));
|
||||
ui->refreshBtn->setIcon(QIcon(":/resources/refresh.png"));
|
||||
|
||||
ui->Wificheckbox->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
|
||||
ui->wifiCheckBox->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->returnBtn->setProperty("type", "borderless");
|
||||
|
||||
// Scroll bar
|
||||
// Needed for the nia.
|
||||
ui->scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 50px; }");
|
||||
|
||||
// Size
|
||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
||||
this->setFixedWidth(screenGeometry.width());
|
||||
|
@ -58,19 +52,19 @@ wifiDialog::wifiDialog(QWidget *parent) :
|
|||
ui->refreshBtn->setFixedHeight(ui->refreshBtn->height() + heighIncrease);
|
||||
|
||||
// And set wifi checkbox state. also ignore this first call
|
||||
global::wifi::WifiState currentWifiState = checkWifiState();
|
||||
if(currentWifiState != global::wifi::WifiState::Disabled and currentWifiState != global::wifi::WifiState::Unknown) {
|
||||
ui->Wificheckbox->setChecked(true);
|
||||
global::wifi::wifiState currentWifiState = checkWifiState();
|
||||
if(currentWifiState != global::wifi::wifiState::disabled and currentWifiState != global::wifi::wifiState::unknown) {
|
||||
ui->wifiCheckBox->setChecked(true);
|
||||
// To be sure nothing breaks
|
||||
refreshFromWatcher = true;
|
||||
ui->refreshBtn->click();
|
||||
} else {
|
||||
wifiButtonEnabled = true;
|
||||
ui->stopBtn->setStyleSheet("background-color:grey;");
|
||||
ui->stopBtn->setStyleSheet("background-color: gray;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
|
||||
// To avoid confussion with reconnecting
|
||||
// To avoid confusion with reconnecting
|
||||
QTimer::singleShot(2000, this, SLOT(theWatcher()));
|
||||
}
|
||||
|
||||
|
@ -82,7 +76,7 @@ wifiDialog::~wifiDialog()
|
|||
void wifiDialog::on_refreshBtn_clicked()
|
||||
{
|
||||
log("Clicked refresh button", className);
|
||||
if(checkWifiState() == global::wifi::WifiState::Disabled) {
|
||||
if(checkWifiState() == global::wifi::wifiState::disabled) {
|
||||
if(refreshFromWatcher == true) {
|
||||
refreshFromWatcher = false;
|
||||
emit showToast("To scan, turn on wi-fi first");
|
||||
|
@ -99,13 +93,13 @@ void wifiDialog::launchRefresh() {
|
|||
// Order is important
|
||||
if(scanInProgress == false) {
|
||||
scanInProgress = true;
|
||||
ui->refreshBtn->setStyleSheet("background-color:grey;");
|
||||
ui->refreshBtn->setStyleSheet("background-color: gray;");
|
||||
ui->refreshBtn->setEnabled(false);
|
||||
|
||||
elapsedSeconds = 0;
|
||||
fullList.remove();
|
||||
formattedList.remove();
|
||||
string_writeconfig("/opt/ibxd", "list_wifi_networks\n");
|
||||
writeFile("/opt/ibxd", "list_wifi_networks\n");
|
||||
QTimer::singleShot(0, this, SLOT(refreshWait()));
|
||||
}
|
||||
else {
|
||||
|
@ -116,8 +110,7 @@ void wifiDialog::launchRefresh() {
|
|||
void wifiDialog::refreshWait() {
|
||||
if(fullList.exists() == false and formattedList.exists() == false) {
|
||||
if(elapsedSeconds == 6) {
|
||||
emit showToast("Failed to get network list");
|
||||
log("Failed to get network list", className);
|
||||
emit showToast("Failed to get networks list");
|
||||
ui->refreshBtn->setStyleSheet("background-color:white;");
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
scanInProgress = false;
|
||||
|
@ -127,7 +120,7 @@ void wifiDialog::refreshWait() {
|
|||
QTimer::singleShot(1000, this, SLOT(refreshWait()));
|
||||
}
|
||||
} else {
|
||||
log("Happily got network list", className);
|
||||
log("Retrieved network list successfully", className);
|
||||
refreshNetworksList();
|
||||
}
|
||||
}
|
||||
|
@ -141,44 +134,46 @@ void wifiDialog::refreshNetworksList() {
|
|||
int count = 1;
|
||||
global::wifi::wifiNetworkData singleNetwork;
|
||||
if(data.count() < 4) {
|
||||
log("Data lines count is below 4, skipping", className);
|
||||
log("Data lines count is below 4; skipping", className);
|
||||
continue;
|
||||
}
|
||||
for(QString singleData: data) {
|
||||
if(count == 1) {
|
||||
singleNetwork.mac = singleData;
|
||||
log("Mac is: " + singleData, className);
|
||||
log("MAC is: " + singleData, className);
|
||||
}
|
||||
if(count == 2) {
|
||||
log("wifi name is: " + singleData, className);
|
||||
if(singleData.isEmpty() == true) {
|
||||
log("Wifi name is empty", className);
|
||||
log("Network name is empty", className);
|
||||
}
|
||||
else {
|
||||
log("Network name is: " + singleData, className);
|
||||
}
|
||||
singleNetwork.name = singleData;
|
||||
}
|
||||
if(count == 3) {
|
||||
log("encryption is: " + singleData, className);
|
||||
log("Encryption type is: " + singleData, className);
|
||||
singleNetwork.encryption = QVariant(singleData).toBool();
|
||||
}
|
||||
if(count == 4) {
|
||||
log("signal strength is: " + singleData, className);
|
||||
log("Signal strength is: " + singleData, className);
|
||||
singleNetwork.signal = QVariant(singleData).toInt();
|
||||
}
|
||||
if(count >= 5) {
|
||||
log("Skipping additionall items in wifi", className);
|
||||
log("Skipping additional items from network information", className);
|
||||
}
|
||||
count = count + 1;
|
||||
}
|
||||
// Really filter out empty networks
|
||||
// Filter out remaining empty networks
|
||||
if(singleNetwork.name.isEmpty() == false) {
|
||||
pureNetworkList.append(singleNetwork);
|
||||
}
|
||||
}
|
||||
log("found valid networks: " + QString::number(pureNetworkList.count()), className);
|
||||
log("Found " + QString::number(pureNetworkList.count()) + " valid networks", className);
|
||||
if(pureNetworkList.count() == 0) {
|
||||
if(secondScanTry == false) {
|
||||
secondScanTry = true;
|
||||
if(checkWifiState() != global::wifi::WifiState::Disabled) {
|
||||
if(checkWifiState() != global::wifi::wifiState::disabled) {
|
||||
scanInProgress = false;
|
||||
QTimer::singleShot(0, this, SLOT(launchRefresh()));
|
||||
log("No networks found. Trying one more time");
|
||||
|
@ -193,21 +188,21 @@ void wifiDialog::refreshNetworksList() {
|
|||
log("No networks found, skipping", className);
|
||||
showToastSlot("No networks found");
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
ui->refreshBtn->setStyleSheet("background-color:white;");
|
||||
ui->refreshBtn->setStyleSheet("background-color: white;");
|
||||
scanInProgress = false;
|
||||
return void();
|
||||
}
|
||||
}
|
||||
QFile currentWifiNameFile = QFile("/external_root/run/current_wifi_name");
|
||||
currentWifiNameFile.remove();
|
||||
string_writeconfig("/opt/ibxd", "get_current_wifi_name\n");
|
||||
writeFile("/opt/ibxd", "get_current_wifi_name\n");
|
||||
usleep(300000); // 0.3s
|
||||
// Here its looking for the now connected network to put it on top
|
||||
// Here, it's looking for the currently connected network to put it on top of the list
|
||||
QString currentNetwork = "";
|
||||
if(currentWifiNameFile.exists() == true) {
|
||||
QString currentWifiNetwork = readFile(currentWifiNameFile.fileName());
|
||||
currentWifiNetwork = currentWifiNetwork.replace("\n", "");
|
||||
log("current network name is: " + currentWifiNetwork, className);
|
||||
log("Current network name is: " + currentWifiNetwork, className);
|
||||
int countVec = 0;
|
||||
int vectorNetworkLocation = 9999;
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
|
||||
|
@ -220,9 +215,9 @@ void wifiDialog::refreshNetworksList() {
|
|||
// To be really sure that the the info is put there
|
||||
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||
connectedNetworkDataParent = wifiNetwork;
|
||||
connectedNetworkDataParentSetted = true;
|
||||
connectedNetworkDataParentSet = true;
|
||||
|
||||
// This doesnt work so a layout is needed
|
||||
// This doesn't work, so a layout is needed
|
||||
// ui->scrollArea->addScrollBarWidget(connectedNetwork, Qt::AlignTop);
|
||||
connectedNetwork->applyVariables();
|
||||
connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::closeWrapper);
|
||||
|
@ -235,14 +230,10 @@ void wifiDialog::refreshNetworksList() {
|
|||
}
|
||||
}
|
||||
if(vectorNetworkLocation != 9999) {
|
||||
log("pureNetworkList size is: " + QString::number(pureNetworkList.count()) + " And i want to remove at: " + QString::number(vectorNetworkLocation), className);
|
||||
log("pureNetworkList size is: " + QString::number(pureNetworkList.count()) + ", entry at " + QString::number(vectorNetworkLocation) + " slated for removal", className);
|
||||
pureNetworkList.removeAt(vectorNetworkLocation);
|
||||
}
|
||||
}
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) {
|
||||
log("signal strength without sorting: " + QString::number(wifiNetwork.signal), className);
|
||||
}
|
||||
|
||||
|
||||
// Sort based on signal strength
|
||||
QVector<global::wifi::wifiNetworkData> sortedPureNetworkList;
|
||||
|
@ -260,19 +251,18 @@ void wifiDialog::refreshNetworksList() {
|
|||
counter = counter + 1;
|
||||
}
|
||||
}
|
||||
// This happens if its the smallest value, so insert it at the end
|
||||
// This happens if it's the smallest value, so insert it at the end
|
||||
if(stopIterating == false) {
|
||||
sortedPureNetworkList.append(wifiNetwork);
|
||||
}
|
||||
}
|
||||
|
||||
log("There are " + QString::number(sortedPureNetworkList.count()) + " sorted networks", className);
|
||||
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||
log("signal strength with sorting: " + QString::number(wifiNetwork.signal), className);
|
||||
log("Signal strength with sorting: " + QString::number(wifiNetwork.signal), className);
|
||||
}
|
||||
|
||||
// And now rest of the networks
|
||||
// And now, handle the remainder of the networks
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||
network* connectedNetwork = new network;
|
||||
connectedNetwork->mainData = wifiNetwork;
|
||||
|
@ -291,24 +281,24 @@ void wifiDialog::refreshNetworksList() {
|
|||
}
|
||||
|
||||
|
||||
void wifiDialog::on_Wificheckbox_stateChanged(int arg1)
|
||||
void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
if(ignoreCheckboxCall == false) {
|
||||
connectedNetworkDataParentSetted = false;
|
||||
if(ignoreCheckBoxCall == false) {
|
||||
connectedNetworkDataParentSet = false;
|
||||
log("wifi dialog clicked: " + QString::number(arg1), className);
|
||||
if(wifiButtonEnabled == true) {
|
||||
if(arg1 == 2) {
|
||||
log("turning wifi on", className);
|
||||
log("Turning Wi-Fi on", className);
|
||||
// the watcher will scan wifi
|
||||
QTimer::singleShot(0, this, SLOT(turnOnWifi()));
|
||||
ui->stopBtn->setStyleSheet("background-color:white;");
|
||||
ui->stopBtn->setStyleSheet("background-color: white;");
|
||||
ui->stopBtn->setEnabled(true);
|
||||
} else {
|
||||
log("turning wifi off", className);
|
||||
log("Turning Wi-Fi off", className);
|
||||
QTimer::singleShot(0, this, SLOT(turnOffWifi()));
|
||||
// To inform the wifi icon GUI to don't show the connected / failed to connect message
|
||||
// To inform the wifi icon GUI to don't show the connected/failed to connect message
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
|
||||
ui->stopBtn->setStyleSheet("background-color:grey;");
|
||||
ui->stopBtn->setStyleSheet("background-color: gray;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
emit killNetworkWidgets();
|
||||
|
@ -318,8 +308,8 @@ void wifiDialog::on_Wificheckbox_stateChanged(int arg1)
|
|||
}
|
||||
}
|
||||
else {
|
||||
ignoreCheckboxCall = false;
|
||||
if(checkWifiState() != global::wifi::WifiState::Disabled) {
|
||||
ignoreCheckBoxCall = false;
|
||||
if(checkWifiState() != global::wifi::wifiState::disabled) {
|
||||
emit killNetworkWidgets();
|
||||
forceRefresh = true;
|
||||
}
|
||||
|
@ -342,13 +332,13 @@ void wifiDialog::turnOffWifi() {
|
|||
|
||||
void wifiDialog::on_logBtn_clicked()
|
||||
{
|
||||
// To avoid half informations
|
||||
if(scannedAtLeastOnce == false and checkWifiState() == global::wifi::WifiState::Configured) {
|
||||
// To avoid half of the information
|
||||
if(scannedAtLeastOnce == false and checkWifiState() == global::wifi::wifiState::configured) {
|
||||
log("Scanning at least once is needed");
|
||||
emit showToast("Scan at least once");
|
||||
} else {
|
||||
wifilogger* wifiLoggerDialog = new wifilogger;
|
||||
if(connectedNetworkDataParentSetted == true) {
|
||||
if(connectedNetworkDataParentSet == true) {
|
||||
wifiLoggerDialog->connectedNetworkData = connectedNetworkDataParent;
|
||||
wifiLoggerDialog->isThereData = true;
|
||||
}
|
||||
|
@ -365,56 +355,54 @@ void wifiDialog::refreshScreenSlot() {
|
|||
}
|
||||
|
||||
/*
|
||||
Some documentation used by the watcher
|
||||
connection_manager.sh - Manages all things, launches other processes
|
||||
connect_to_network.sh - All in one connection manager. manages everything, used by ipd, should be used for recconections after sleeping / booting
|
||||
get_dhcp.sh - Gets dhcp addresses
|
||||
prepare_changing_wifi.sh - Kills everything, prepares to changing network
|
||||
smarter_time_sync.sh - Synces time
|
||||
toggle.sh - Turns on / off
|
||||
list_networks.bin - Well lists networks
|
||||
check_wifi_password.sh - Checks wifi password
|
||||
theWatcher() first watches at processes that could kill other ones
|
||||
Some documentation used by the watcher
|
||||
* connection_manager.sh - Manages all things, launches other processes
|
||||
* connect_to_network.sh - All-in-one connection manager. Manages everything, used by IPD, should be used for Wi-Fi reconnections after sleeping/booting
|
||||
* get_dhcp.sh - Gets dhcp addresses
|
||||
* prepare_changing_wifi.sh - Kills everything, prepares to changing network
|
||||
* smarter_time_sync.sh - Syncs time
|
||||
* toggle.sh - Turns on/off Wi-Fi adapter
|
||||
* list_networks.bin - Lists networks
|
||||
* check_wifi_password.sh - Checks Wi-Fi network password
|
||||
* watcher() first watches at processes that could kill other ones
|
||||
*/
|
||||
|
||||
void wifiDialog::theWatcher() {
|
||||
|
||||
void wifiDialog::watcher() {
|
||||
bool killing = checkProcessName("toggle.sh");
|
||||
bool changing = checkProcessName("prepare_changing_wifi.sh");
|
||||
if(killing == true) {
|
||||
setStatusText("Changing wifi state");
|
||||
//log("toggle.sh is active", className);
|
||||
setStatusText("Changing Wi-Fi adapter status");
|
||||
isToggleRunning = true;
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
if(changing == true) {
|
||||
setStatusText("Disconnecting from a network or cleaning");
|
||||
setStatusText("Disconnecting from a network or cleaning up");
|
||||
log("prepare_changing_wifi.sh is active", className);
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
bool recconection = checkProcessName("connect_to_network.sh");
|
||||
if(recconection == true) {
|
||||
bool reconnection = checkProcessName("connect_to_network.sh");
|
||||
if(reconnection == true) {
|
||||
forceRefresh = true;
|
||||
QFile recName = QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid");
|
||||
if(recName.exists() == true) {
|
||||
setStatusText("Recconecting after suspending to " + readFile(recName.fileName()).replace("\n", ""));
|
||||
setStatusText("Reconnecting after suspending to " + readFile(recName.fileName()).replace("\n", ""));
|
||||
}
|
||||
else {
|
||||
// Shouldn't be possible
|
||||
setStatusText("Recconecting after sleep");
|
||||
setStatusText("Reconnecting after sleep");
|
||||
}
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
bool listing = checkProcessName("list_networks.bin");
|
||||
if(listing == true) {
|
||||
setStatusText("Scanning networks...");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
setStatusText("Scanning networks ...");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -422,33 +410,31 @@ void wifiDialog::theWatcher() {
|
|||
if(dhcp == true) {
|
||||
forceRefresh = true;
|
||||
setStatusText("Getting IP address");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
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()));
|
||||
setStatusText("Checking Wi-Fi network password");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
bool time = checkProcessName("smarter_time_sync.sh");
|
||||
if(time == true) {
|
||||
forceRefresh = true;
|
||||
setStatusText("Syncing time");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
setStatusText("Syncing");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
|
||||
bool connecting = checkProcessName("connection_manager.sh");
|
||||
if(connecting == true) {
|
||||
forceRefresh = true;
|
||||
setStatusText("Connecting to wifi...");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
setStatusText("Connecting to Wi-Fi network ...");
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
}
|
||||
|
||||
|
@ -456,26 +442,26 @@ void wifiDialog::theWatcher() {
|
|||
setStatusText("Idling");
|
||||
}
|
||||
|
||||
if(unlockCheckbox == true) {
|
||||
ui->Wificheckbox->setEnabled(true);
|
||||
unlockCheckbox = false;
|
||||
if(unlockCheckBox == true) {
|
||||
ui->wifiCheckBox->setEnabled(true);
|
||||
unlockCheckBox = false;
|
||||
}
|
||||
|
||||
if(isToggleRunning == true) {
|
||||
isToggleRunning = false;
|
||||
// To make sure the checkbox is in the right state
|
||||
if(checkWifiState() == global::wifi::WifiState::Disabled) {
|
||||
// Make sure the checkbox is in the right state
|
||||
if(checkWifiState() == global::wifi::wifiState::disabled) {
|
||||
// In this state, ignore forceRefresh to avoid message
|
||||
forceRefresh = false;
|
||||
if(ui->Wificheckbox->isChecked() == true) {
|
||||
ignoreCheckboxCall = true;
|
||||
ui->Wificheckbox->setChecked(false);
|
||||
if(ui->wifiCheckBox->isChecked() == true) {
|
||||
ignoreCheckBoxCall = true;
|
||||
ui->wifiCheckBox->setChecked(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(ui->Wificheckbox->isChecked() == false) {
|
||||
ignoreCheckboxCall = true;
|
||||
ui->Wificheckbox->setChecked(true);
|
||||
if(ui->wifiCheckBox->isChecked() == false) {
|
||||
ignoreCheckBoxCall = true;
|
||||
ui->wifiCheckBox->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +472,7 @@ void wifiDialog::theWatcher() {
|
|||
QTimer::singleShot(1500, this, SLOT(waitToScan()));
|
||||
}
|
||||
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(theWatcher()));
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
}
|
||||
|
||||
void wifiDialog::setStatusText(QString message) {
|
||||
|
@ -496,23 +482,18 @@ void wifiDialog::setStatusText(QString message) {
|
|||
void wifiDialog::on_stopBtn_clicked()
|
||||
{
|
||||
log("Stop button was clicked", className);
|
||||
connectedNetworkDataParentSetted = false;
|
||||
ui->Wificheckbox->setEnabled(false);
|
||||
unlockCheckbox = true;
|
||||
connectedNetworkDataParentSet = false;
|
||||
ui->wifiCheckBox->setEnabled(false);
|
||||
unlockCheckBox = true;
|
||||
|
||||
// To inform the wifi icon GUI to don't show the connected / failed to connect message
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
|
||||
|
||||
// Maybe limit this, idk
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
// To inform the wifi icon GUI to don't show the connected/failed to connect message
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
|
||||
writeFile("/opt/ibxd", "stop_wifi_operations\n");
|
||||
|
||||
QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").remove();
|
||||
QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase").remove();
|
||||
|
||||
// This variable just avoids showing the toast so i can use it here too...
|
||||
// Actually refreshing from watcher is smarter so this isin't needed
|
||||
//refreshFromWatcher = true;
|
||||
//ui->refreshBtn->click();
|
||||
// This variable just avoids showing the toast, so it is usable here too
|
||||
waitToScan();
|
||||
}
|
||||
|
||||
|
@ -523,7 +504,7 @@ void wifiDialog::on_returnBtn_clicked()
|
|||
}
|
||||
|
||||
void wifiDialog::waitToScan() {
|
||||
if(checkWifiState() != global::wifi::WifiState::Disabled) {
|
||||
if(checkWifiState() != global::wifi::wifiState::disabled) {
|
||||
ui->refreshBtn->click();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -20,8 +20,7 @@ public:
|
|||
explicit wifiDialog(QWidget *parent = nullptr);
|
||||
~wifiDialog();
|
||||
global::wifi::wifiNetworkData connectedNetworkDataParent;
|
||||
// well dont touch this until there is something, *** Error in `/tmp/exec': double free or corruption (fasttop): 0x025ed170 ***
|
||||
bool connectedNetworkDataParentSetted = false;
|
||||
bool connectedNetworkDataParentSet = false;
|
||||
|
||||
private:
|
||||
Ui::wifiDialog *ui;
|
||||
|
@ -37,11 +36,11 @@ private:
|
|||
bool forceRefresh = false;
|
||||
int relaunchMs = 300;
|
||||
bool refreshFromWatcher = false;
|
||||
bool unlockCheckbox = false;
|
||||
bool unlockCheckBox = false;
|
||||
bool scanInProgress = false;
|
||||
|
||||
bool isToggleRunning = false;
|
||||
bool ignoreCheckboxCall = false;
|
||||
bool ignoreCheckBoxCall = false;
|
||||
|
||||
bool secondScanTry = false;
|
||||
|
||||
|
@ -51,24 +50,25 @@ public slots:
|
|||
void showToastSlot(QString message);
|
||||
void refreshScreenSlot();
|
||||
|
||||
// Shows status of wifi processes, like recconection and others. Also manages refreshing the network list after connection
|
||||
void theWatcher();
|
||||
// Shows status of Wi-Fi processes, like reconnection and others. Also manages refreshing the networks list after connection
|
||||
void watcher();
|
||||
|
||||
signals:
|
||||
void refreshScreen();
|
||||
void updateWifiIconSig(int mode);
|
||||
void showToast(QString messageToDisplay);
|
||||
|
||||
void killNetworkWidgets();
|
||||
|
||||
private slots:
|
||||
void on_refreshBtn_clicked();
|
||||
void on_Wificheckbox_stateChanged(int arg1);
|
||||
void on_wifiCheckBox_stateChanged(int arg1);
|
||||
void turnOnWifi();
|
||||
void turnOffWifi();
|
||||
void on_logBtn_clicked();
|
||||
// This function is a more clever sleep(1), non blocking
|
||||
|
||||
// This function is a more clever sleep(1), non-blocking
|
||||
void refreshWait();
|
||||
|
||||
void setStatusText(QString message);
|
||||
void on_stopBtn_clicked();
|
||||
void on_returnBtn_clicked();
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="Wificheckbox">
|
||||
<widget class="QCheckBox" name="wifiCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
|
|
@ -38,14 +38,14 @@ wifilogger::~wifilogger()
|
|||
}
|
||||
|
||||
void wifilogger::setWifiInfoPage() {
|
||||
if(checkWifiState() == global::wifi::WifiState::Configured) {
|
||||
QTimer::singleShot(0, this, SLOT(getWifiInformations()));
|
||||
if(checkWifiState() == global::wifi::wifiState::configured) {
|
||||
QTimer::singleShot(0, this, SLOT(getWifiInformation()));
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
ui->nameLabel->setText("Network informations");
|
||||
ui->nameLabel->setText("Network information");
|
||||
}
|
||||
else {
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
ui->nameLabel->setText("No network connected");
|
||||
ui->nameLabel->setText("Not currently connected to a network");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,27 +97,27 @@ void wifilogger::changePage() {
|
|||
}
|
||||
}
|
||||
|
||||
void wifilogger::getWifiInformations() {
|
||||
log("getting wifi informations", className);
|
||||
QFile wifiInformationsPath = QFile("/external_root/run/wifi_informations");
|
||||
void wifilogger::getWifiInformation() {
|
||||
log("Retrieving Wi-Fi information", className);
|
||||
QFile wifiInformationPath = QFile("/external_root/run/wifi_information");
|
||||
if(waitingForFile == false) {
|
||||
wifiInformationsPath.remove();
|
||||
wifiInformationPath.remove();
|
||||
|
||||
log("Launching get_wifi_informations ibxd call", className);
|
||||
string_writeconfig("/opt/ibxd", "get_wifi_informations\n");
|
||||
log("Sending get_wifi_information ibxd call", className);
|
||||
string_writeconfig("/opt/ibxd", "get_wifi_information\n");
|
||||
waitingForFile = true;
|
||||
}
|
||||
|
||||
if(waitingForFile == true) {
|
||||
if(wifiInformationsPath.exists() == false) {
|
||||
QTimer::singleShot(1000, this, SLOT(getWifiInformations()));
|
||||
if(wifiInformationPath.exists() == false) {
|
||||
QTimer::singleShot(1000, this, SLOT(getWifiInformation()));
|
||||
return void();
|
||||
}
|
||||
}
|
||||
|
||||
waitingForFile = false;
|
||||
log("Setting variables", className);
|
||||
QString wifiInfo = readFile(wifiInformationsPath.fileName());
|
||||
QString wifiInfo = readFile(wifiInformationPath.fileName());
|
||||
QStringList wifiInfoList = wifiInfo.split("\n");
|
||||
int counter = 0;
|
||||
for(QString infomation: wifiInfoList) {
|
||||
|
@ -138,17 +138,13 @@ void wifilogger::getWifiInformations() {
|
|||
|
||||
if(isThereData == true) {
|
||||
ui->encryptionLabel->setText(QVariant(connectedNetworkData.encryption).toString());
|
||||
|
||||
ui->signalLabel->setText(QString::number(connectedNetworkData.signal) + "%");
|
||||
|
||||
ui->macLabel->setText(connectedNetworkData.mac);
|
||||
}
|
||||
else {
|
||||
// Shouldn't happen for 99%, but if anyway... its designed to be non blocking, so i cant really wait for this.
|
||||
// Shouldn't happen for 99%, but if anyway... it's designed to be non-blocking, so I can't really wait for this.
|
||||
ui->encryptionLabel->setText("Rescan needed");
|
||||
|
||||
ui->signalLabel->setText("Rescan needed");
|
||||
|
||||
ui->macLabel->setText("Rescan needed");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,15 +17,15 @@ public:
|
|||
explicit wifilogger(QWidget *parent = nullptr);
|
||||
~wifilogger();
|
||||
global::wifi::wifiNetworkData connectedNetworkData;
|
||||
// to the above value
|
||||
// To the above value
|
||||
bool isThereData = false;
|
||||
|
||||
private:
|
||||
Ui::wifilogger *ui;
|
||||
/*
|
||||
* 0 is wifi info / no wifi info page
|
||||
* 1 is fancy logs page
|
||||
* 2 is all logs
|
||||
* 0 Is Wi-Fi info/no Wi-Fi info page
|
||||
* 1 Is fancy logs page
|
||||
* 2 Is all logs page
|
||||
*/
|
||||
int currentPage = 0;
|
||||
QFile fancyLogs = QFile("/external_root/run/wifi_stats");
|
||||
|
@ -39,7 +39,7 @@ private slots:
|
|||
void on_nextBtn_clicked();
|
||||
void on_previousBtn_clicked();
|
||||
void changePage();
|
||||
void getWifiInformations();
|
||||
void getWifiInformation();
|
||||
void on_returnBtn_clicked();
|
||||
void updateLogs();
|
||||
void on_refreshBtn_clicked();
|
||||
|
|
Loading…
Reference in a new issue