mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -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);
|
||||
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
|
||||
|
|
|
@ -380,6 +380,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
}
|
||||
}
|
||||
else if(ui->searchComboBox->currentText() == "Online library") {
|
||||
if(testPing() == 0) {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
|
||||
|
||||
if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) {
|
||||
|
@ -415,7 +416,8 @@ void generalDialog::on_okBtn_clicked()
|
|||
searchTimer->start();
|
||||
}
|
||||
else {
|
||||
;
|
||||
emit showToast("Wi-Fi connection error");
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
/* Usage:
|
||||
* mode 0: auto
|
||||
|
@ -1101,6 +1086,7 @@ void MainWindow::openEncfsRepackDialog() {
|
|||
|
||||
void MainWindow::on_libraryButton_clicked()
|
||||
{
|
||||
if(testPing() == 0) {
|
||||
resetFullWindowException = false;
|
||||
resetWindow(false);
|
||||
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
|
||||
|
@ -1121,8 +1107,9 @@ void MainWindow::on_libraryButton_clicked()
|
|||
// Repaint
|
||||
this->repaint();
|
||||
}
|
||||
}
|
||||
else {
|
||||
;
|
||||
showToast("Wi-Fi connection error");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
void openUsbmsDialog();
|
||||
void resetIcons();
|
||||
void setBatteryIcon();
|
||||
int testPing();
|
||||
bool checkWifiState();
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in a new issue