From 595da4b6be69615510892d40ef7aac43d3e417a8 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Tue, 20 Jul 2021 23:27:32 -0400 Subject: [PATCH] Some fixes for Wi-Fi dialog; IP address in System Info --- functions.h | 15 +++++++++++++++ generaldialog.cpp | 2 ++ inkbox.pro | 5 ++++- mainwindow.cpp | 16 ++++++++++++++++ mainwindow.h | 3 +++ otamanager.cpp | 32 ++++++++++++++++++++++++++++++++ otamanager.h | 26 ++++++++++++++++++++++++++ otamanager.ui | 21 +++++++++++++++++++++ 8 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 otamanager.cpp create mode 100644 otamanager.h create mode 100644 otamanager.ui diff --git a/functions.h b/functions.h index 373b75d..59f4e46 100644 --- a/functions.h +++ b/functions.h @@ -374,6 +374,17 @@ namespace { kernelVersion.append(", build "); kernelVersion.append(kernelBuildID); } + QString getConnectionInformation() { + QString getIpProg ("sh"); + QStringList getIpArgs; + getIpArgs << "-c" << "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'"; + QProcess *getIpProc = new QProcess(); + getIpProc->start(getIpProg, getIpArgs); + getIpProc->waitForFinished(); + + QString ipAddress = getIpProc->readAllStandardOutput(); + return ipAddress; + } void getSystemInfo() { getUID(); getKernelVersion(); @@ -389,6 +400,10 @@ namespace { string_checkconfig_ro("/opt/inkbox_device"); QString device = checkconfig_str_val.trimmed(); global::systemInfoText.append(device); + QString ipAddress = getConnectionInformation(); + global::systemInfoText.append("
IP address: "); + global::systemInfoText.append(ipAddress); + } void resetKoboxUserData() { global::kobox::resetKoboxUserDataBool = true; diff --git a/generaldialog.cpp b/generaldialog.cpp index 1d2b70b..28e8894 100644 --- a/generaldialog.cpp +++ b/generaldialog.cpp @@ -278,6 +278,8 @@ void generalDialog::on_okBtn_clicked() global::toast::modalToast = true; emit showToast("Connecting"); QTimer::singleShot(100, this, SLOT(connectToNetworkSlot())); + global::keyboard::wifiPassphraseDialog = false; + global::keyboard::keyboardDialog = false; } else { QMessageBox::critical(this, tr("Invalid argument"), tr("Please type in the required argument.")); diff --git a/inkbox.pro b/inkbox.pro index aeda9de..6356d96 100644 --- a/inkbox.pro +++ b/inkbox.pro @@ -1,4 +1,4 @@ -QT += core gui +QT += core gui network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -21,6 +21,7 @@ SOURCES += \ koboxsettings.cpp \ main.cpp \ mainwindow.cpp \ + otamanager.cpp \ quit.cpp \ reader.cpp \ savedwords.cpp \ @@ -44,6 +45,7 @@ HEADERS += \ koboxappsdialog.h \ koboxsettings.h \ mainwindow.h \ + otamanager.h \ quit.h \ reader.h \ savedwords.h \ @@ -66,6 +68,7 @@ FORMS += \ koboxappsdialog.ui \ koboxsettings.ui \ mainwindow.ui \ + otamanager.ui \ quit.ui \ reader.ui \ savedwords.ui \ diff --git a/mainwindow.cpp b/mainwindow.cpp index af16432..22320e5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -601,6 +601,7 @@ void MainWindow::on_settingsBtn_clicked() else { ; } + showToast("Connection successful"); } void MainWindow::on_appsBtn_clicked() @@ -950,6 +951,12 @@ void MainWindow::showToast(QString messageToDisplay) { connect(toastWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString))); connect(toastWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast())); toastWindow->show(); + + if(messageToDisplay == "Connection successful") { + otaManagerWindow = new otaManager(this); + connect(otaManagerWindow, SIGNAL(canInstallOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool))); + otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose); + } } void MainWindow::hello(int testNumber) { @@ -960,3 +967,12 @@ void MainWindow::closeIndefiniteToast() { // Warning: use with caution toastWindow->close(); } + +void MainWindow::openUpdateDialogOTA(bool open) { + if(open == true) { + openUpdateDialog(); + } + else { + ; + } +} diff --git a/mainwindow.h b/mainwindow.h index dce06a7..edc2cc3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -16,6 +16,7 @@ #include "textwidget.h" #include "virtualkeypad.h" #include "toast.h" +#include "otamanager.h" using namespace std; @@ -82,6 +83,7 @@ private slots: void hello(int testNumber); void showToast(QString messageToDisplay); void closeIndefiniteToast(); + void openUpdateDialogOTA(bool open); private: Ui::MainWindow *ui; @@ -98,6 +100,7 @@ private: textwidget *textwidgetWindow; virtualkeypad *keypadWidget; toast *toastWindow; + otaManager *otaManagerWindow; }; #endif // MAINWINDOW_H diff --git a/otamanager.cpp b/otamanager.cpp new file mode 100644 index 0000000..fe39986 --- /dev/null +++ b/otamanager.cpp @@ -0,0 +1,32 @@ +#include "otamanager.h" +#include "ui_otamanager.h" +#include "functions.h" + +#include + +otaManager::otaManager(QWidget *parent) : + QWidget(parent), + ui(new Ui::otaManager) +{ + ui->setupUi(this); + string_writeconfig("/opt/ibxd", "ota_update_check\n"); + QTimer *otaCheckTimer = new QTimer(); + otaCheckTimer->setInterval(100); + connect(otaCheckTimer, &QTimer::timeout, [&]() { + if(QFile::exists("/run/can_install_ota_update") == true) { + if(checkconfig("/run/can_install_ota_update") == true) { + emit canInstallOtaUpdate(true); + otaManager::close(); + } + else { + emit canInstallOtaUpdate(false); + otaManager::close(); + } + } + } ); +} + +otaManager::~otaManager() +{ + delete ui; +} diff --git a/otamanager.h b/otamanager.h new file mode 100644 index 0000000..bff50c3 --- /dev/null +++ b/otamanager.h @@ -0,0 +1,26 @@ +#ifndef OTAMANAGER_H +#define OTAMANAGER_H + +#include + +namespace Ui { +class otaManager; +} + +class otaManager : public QWidget +{ + Q_OBJECT + +public: + explicit otaManager(QWidget *parent = nullptr); + ~otaManager(); + +private: + Ui::otaManager *ui; + +signals: + void canInstallOtaUpdate(bool yesno); + +}; + +#endif // OTAMANAGER_H diff --git a/otamanager.ui b/otamanager.ui new file mode 100644 index 0000000..72f0ae2 --- /dev/null +++ b/otamanager.ui @@ -0,0 +1,21 @@ + + + + + otamanager + + + + 0 + 0 + 400 + 300 + + + + Form + + + + +