From 7ceed8d98857802fe79d6e45a6596bee5ad4139c Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sun, 14 Jan 2024 19:23:46 +0000 Subject: [PATCH] Settings: Add option to enable USBNet from GUI (rooted kernels) --- src/settings/settings.cpp | 18 +++ src/settings/settings.h | 1 + src/settings/settings.ui | 332 ++++++++++++++++++++------------------ 3 files changed, 190 insertions(+), 161 deletions(-) diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 96b3e6b..bea05bf 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -124,6 +124,7 @@ settings::settings(QWidget *parent) : ui->securitySettingsBtn->setIcon(QIcon(":/resources/lock.png")); ui->securitySettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight)); + ui->usbNetworkingCheckBox->hide(); ui->requestLeaseBtn->hide(); ui->usbmsBtn->hide(); ui->label_4->hide(); @@ -412,10 +413,15 @@ settings::settings(QWidget *parent) : if(checkconfig("/opt/inkbox_genuine") == true) { // Enforcing security policy if the user has not rooted the device if(checkconfig("/external_root/opt/root/rooted") == true) { + ui->usbNetworkingCheckBox->show(); + if(checkconfig("/external_root/boot/flags/USBNET_ENABLE")) { + ui->usbNetworkingCheckBox->click(); + } ui->requestLeaseBtn->show(); ui->label_4->show(); } else { + ui->usbNetworkingCheckBox->hide(); ui->requestLeaseBtn->hide(); ui->label_4->hide(); } @@ -1163,3 +1169,15 @@ void settings::on_headerBtn_clicked() log("'Home' button clicked", className); ui->settingsStackedWidget->setCurrentIndex(0); } + +void settings::on_usbNetworkingCheckBox_toggled(bool checked) +{ + if(checked) { + writeFile("/external_root/boot/flags/USBNET_ENABLE", "true"); + writeFile("/opt/ibxd", "usbnet_start\n"); + } + else { + writeFile("/external_root/boot/flags/USBNET_ENABLE", "false"); + writeFile("/opt/ibxd", "usbnet_stop\n"); + } +} diff --git a/src/settings/settings.h b/src/settings/settings.h index d8ec4c9..29744fc 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -90,6 +90,7 @@ private slots: void on_systemSettingsBtn_clicked(); void on_securitySettingsBtn_clicked(); void on_headerBtn_clicked(); + void on_usbNetworkingCheckBox_toggled(bool checked); signals: void showToast(QString messageToDisplay); diff --git a/src/settings/settings.ui b/src/settings/settings.ui index ad76896..c1eec0c 100644 --- a/src/settings/settings.ui +++ b/src/settings/settings.ui @@ -200,8 +200,8 @@ 0 0 - 457 - 610 + 461 + 636 @@ -407,8 +407,8 @@ Save && Quit 0 0 - 419 - 387 + 423 + 738 @@ -931,28 +931,29 @@ Save && Quit + + 0 + 0 - - + + 0 - - - - - true - - + + 0 + + + - Reset + System info - + Qt::Horizontal @@ -964,16 +965,112 @@ Save && Quit - - + + + + + true + + - Reset this device + Show - + + + + 0 + + + + + + true + + + + Check + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Check for updates + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Request DHCP lease + + + + + + + + true + + + + Request + + + + + + 0 @@ -1015,7 +1112,53 @@ Save && Quit - + + + + Enable night mode + + + + + + + 0 + + + + + + true + + + + Reset + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Reset this device + + + + + + 0 @@ -1066,88 +1209,7 @@ Save && Quit - - - - 0 - - - - - - true - - - - Request - - - - - - - Request DHCP lease - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - 0 - - - - - System info - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - true - - - - Show - - - - - - + 0 @@ -1186,14 +1248,7 @@ Save && Quit - - - - Enable night mode - - - - + @@ -1206,46 +1261,7 @@ Save && Quit - - - - 0 - - - - - - true - - - - Check - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Check for updates - - - - - - + 0 @@ -1275,18 +1291,12 @@ Save && Quit - - - - Qt::Vertical + + + + Enable USB networking - - - 20 - 40 - - - +