mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-27 16:17:21 -08:00
Gutenberg: Fix #20
Gutenberg-related services (e.g., 'Online library') will now show an error message if they can't connect to the Internet and refuse to launch.
This commit is contained in:
parent
c12d8c0017
commit
6cc6737d8d
4 changed files with 69 additions and 66 deletions
15
functions.h
15
functions.h
|
@ -693,6 +693,21 @@ namespace {
|
||||||
close(ntxfd);
|
close(ntxfd);
|
||||||
return !!ptr;
|
return !!ptr;
|
||||||
}
|
}
|
||||||
|
int testPing() {
|
||||||
|
QString pingProg = "ping";
|
||||||
|
QStringList pingArgs;
|
||||||
|
pingArgs << "-c" << "1" << "1.1.1.1";
|
||||||
|
QProcess *pingProcess = new QProcess();
|
||||||
|
pingProcess->start(pingProg, pingArgs);
|
||||||
|
pingProcess->waitForFinished();
|
||||||
|
int exitCode = pingProcess->exitCode();
|
||||||
|
pingProcess->deleteLater();
|
||||||
|
if(exitCode == 0) {
|
||||||
|
global::network::isConnected = true;
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FUNCTIONS_H
|
#endif // FUNCTIONS_H
|
||||||
|
|
|
@ -380,6 +380,7 @@ void generalDialog::on_okBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ui->searchComboBox->currentText() == "Online library") {
|
else if(ui->searchComboBox->currentText() == "Online library") {
|
||||||
|
if(testPing() == 0) {
|
||||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
|
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
|
||||||
|
|
||||||
if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) {
|
if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) {
|
||||||
|
@ -415,7 +416,8 @@ void generalDialog::on_okBtn_clicked()
|
||||||
searchTimer->start();
|
searchTimer->start();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
;
|
emit showToast("Wi-Fi connection error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -902,21 +902,6 @@ void MainWindow::setupSearchDialog() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MainWindow::testPing() {
|
|
||||||
QString pingProg = "ping";
|
|
||||||
QStringList pingArgs;
|
|
||||||
pingArgs << "-c" << "1" << "1.1.1.1";
|
|
||||||
QProcess *pingProcess = new QProcess();
|
|
||||||
pingProcess->start(pingProg, pingArgs);
|
|
||||||
pingProcess->waitForFinished();
|
|
||||||
int exitCode = pingProcess->exitCode();
|
|
||||||
pingProcess->deleteLater();
|
|
||||||
if(exitCode == 0) {
|
|
||||||
global::network::isConnected = true;
|
|
||||||
}
|
|
||||||
return exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateWifiIcon(int mode) {
|
void MainWindow::updateWifiIcon(int mode) {
|
||||||
/* Usage:
|
/* Usage:
|
||||||
* mode 0: auto
|
* mode 0: auto
|
||||||
|
@ -1101,6 +1086,7 @@ void MainWindow::openEncfsRepackDialog() {
|
||||||
|
|
||||||
void MainWindow::on_libraryButton_clicked()
|
void MainWindow::on_libraryButton_clicked()
|
||||||
{
|
{
|
||||||
|
if(testPing() == 0) {
|
||||||
resetFullWindowException = false;
|
resetFullWindowException = false;
|
||||||
resetWindow(false);
|
resetWindow(false);
|
||||||
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
|
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
|
||||||
|
@ -1121,8 +1107,9 @@ void MainWindow::on_libraryButton_clicked()
|
||||||
// Repaint
|
// Repaint
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
;
|
showToast("Wi-Fi connection error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ public:
|
||||||
void openUsbmsDialog();
|
void openUsbmsDialog();
|
||||||
void resetIcons();
|
void resetIcons();
|
||||||
void setBatteryIcon();
|
void setBatteryIcon();
|
||||||
int testPing();
|
|
||||||
bool checkWifiState();
|
bool checkWifiState();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in a new issue