2021-03-25 05:00:19 -07:00
|
|
|
#include "usbms_splash.h"
|
|
|
|
#include "ui_usbms_splash.h"
|
|
|
|
|
|
|
|
#include <QPixmap>
|
2021-03-29 05:04:46 -07:00
|
|
|
#include <QScreen>
|
2021-05-09 11:07:05 -07:00
|
|
|
#include <QTimer>
|
2021-03-25 05:00:19 -07:00
|
|
|
|
2021-04-30 20:55:38 -07:00
|
|
|
#include "functions.h"
|
|
|
|
|
2021-03-25 05:00:19 -07:00
|
|
|
usbms_splash::usbms_splash(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::usbms_splash)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2021-03-29 05:04:46 -07:00
|
|
|
// Getting the screen's size
|
|
|
|
float sW = QGuiApplication::screens()[0]->size().width();
|
|
|
|
float sH = QGuiApplication::screens()[0]->size().height();
|
|
|
|
|
2021-03-29 05:14:15 -07:00
|
|
|
// Defining what the default icon size will be
|
2021-04-30 20:55:38 -07:00
|
|
|
if(global::kobox::showKoboxSplash == true) {
|
|
|
|
float stdIconWidth = sW / 1.30;
|
|
|
|
float stdIconHeight = sH / 1.30;
|
|
|
|
|
|
|
|
// Stylesheet
|
|
|
|
QFile stylesheetFile(":/resources/eink.qss");
|
|
|
|
stylesheetFile.open(QFile::ReadOnly);
|
|
|
|
this->setStyleSheet(stylesheetFile.readAll());
|
|
|
|
stylesheetFile.close();
|
|
|
|
|
|
|
|
ui->label->setText("Launching KoBox subsystem");
|
2021-05-07 22:03:25 -07:00
|
|
|
ui->label->setStyleSheet("font-size: 14pt");
|
2021-04-30 20:55:38 -07:00
|
|
|
ui->label_3->setText("Please wait, this could take a while.");
|
2021-05-14 20:44:59 -07:00
|
|
|
string_checkconfig_ro("/opt/inkbox_device");
|
|
|
|
if(checkconfig_str_val == "n905\n") {
|
|
|
|
ui->label_3->setStyleSheet("font-size: 11pt");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui->label_3->setStyleSheet("font-size: 10pt");
|
|
|
|
}
|
2021-04-30 20:55:38 -07:00
|
|
|
|
|
|
|
QPixmap pixmap(":/resources/kobox-icon.png");
|
|
|
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
|
|
|
ui->label_2->setPixmap(scaledPixmap);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float stdIconWidth = sW / 1.15;
|
|
|
|
float stdIconHeight = sH / 1.15;
|
2021-03-29 05:04:46 -07:00
|
|
|
|
2021-04-30 20:55:38 -07:00
|
|
|
this->setStyleSheet("background-color:black;");
|
|
|
|
ui->label->setStyleSheet("QLabel { background-color : black; color : white; }");
|
|
|
|
ui->label_3->setStyleSheet("QLabel { background-color : black; color : white; font-size: 9pt}");
|
2021-03-25 05:00:19 -07:00
|
|
|
|
2021-04-30 20:55:38 -07:00
|
|
|
QPixmap pixmap(":/resources/usbms.png");
|
|
|
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
|
|
|
ui->label_2->setPixmap(scaledPixmap);
|
|
|
|
}
|
2021-05-09 11:07:05 -07:00
|
|
|
|
|
|
|
if(global::usbms::launchUsbms == true) {
|
|
|
|
global::usbms::launchUsbms = false;
|
|
|
|
usbms_launch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void usbms_splash::usbms_launch()
|
|
|
|
{
|
2021-06-29 13:32:31 -07:00
|
|
|
string_writeconfig("/tmp/in_usbms", "true");
|
2021-06-29 12:28:54 -07:00
|
|
|
QTimer::singleShot(1500, this, SLOT(brightnessDown()));
|
2021-06-27 10:28:41 -07:00
|
|
|
|
2021-05-13 18:40:05 -07:00
|
|
|
if(global::usbms::koboxExportExtensions == true) {
|
2021-09-26 13:46:25 -07:00
|
|
|
string_writeconfig("/opt/ibxd", "kobox_extensions_storage_unmount\n");
|
2021-05-13 18:40:05 -07:00
|
|
|
}
|
2021-11-20 11:53:11 -08:00
|
|
|
if(checkconfig("/external_root/run/encfs_mounted") == true) {
|
|
|
|
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true");
|
|
|
|
string_writeconfig("/opt/ibxd", "encfs_stop\n");
|
|
|
|
QThread::msleep(1500);
|
2021-05-13 18:40:05 -07:00
|
|
|
}
|
2021-11-20 11:53:11 -08:00
|
|
|
|
|
|
|
string_writeconfig("/opt/ibxd", "onboard_unmount\n");
|
2021-09-26 13:46:25 -07:00
|
|
|
QThread::msleep(500);
|
|
|
|
|
|
|
|
string_writeconfig("/opt/ibxd", "usbnet_stop\n");
|
2021-09-26 19:05:45 -07:00
|
|
|
QThread::msleep(1000);
|
2021-05-09 11:07:05 -07:00
|
|
|
|
|
|
|
QString prog_1 ("insmod");
|
|
|
|
QStringList args_1;
|
2021-05-13 18:40:05 -07:00
|
|
|
|
|
|
|
if(global::usbms::koboxExportExtensions == true) {
|
2021-05-25 15:23:56 -07:00
|
|
|
args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/X11/extensions-user.img" << "removable=y" << "stall=0";
|
2021-05-13 18:40:05 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/onboard" << "removable=y" << "stall=0";
|
|
|
|
}
|
|
|
|
|
2021-05-09 11:07:05 -07:00
|
|
|
QProcess *proc_1 = new QProcess();
|
|
|
|
proc_1->start(prog_1, args_1);
|
|
|
|
proc_1->waitForFinished();
|
2021-08-29 12:05:07 -07:00
|
|
|
proc_1->deleteLater();
|
2021-05-09 11:07:05 -07:00
|
|
|
|
|
|
|
QTimer *usbms_t = new QTimer(this);
|
|
|
|
usbms_t->setInterval(1000);
|
|
|
|
connect(usbms_t, &QTimer::timeout, [&]() {
|
|
|
|
QString prog ("mass_storage.sh");
|
|
|
|
QStringList args;
|
|
|
|
QProcess *proc = new QProcess();
|
|
|
|
proc->start(prog, args);
|
|
|
|
proc->waitForFinished();
|
2021-08-29 12:05:07 -07:00
|
|
|
proc->deleteLater();
|
2021-05-09 11:07:05 -07:00
|
|
|
|
|
|
|
QFile modules("/tmp/usbevent");
|
|
|
|
modules.open(QIODevice::ReadWrite);
|
|
|
|
QTextStream in (&modules);
|
|
|
|
const QString content = in.readAll();
|
|
|
|
std::string contentstr = content.toStdString();
|
|
|
|
modules.close();
|
|
|
|
if(contentstr.find("1") != std::string::npos) {
|
2021-09-26 13:46:25 -07:00
|
|
|
if(global::usbms::koboxExportExtensions == true) {
|
|
|
|
reboot(false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QString prog("rmmod");
|
|
|
|
QStringList args;
|
|
|
|
args << "g_mass_storage";
|
|
|
|
QProcess * proc = new QProcess();
|
|
|
|
proc->start(prog, args);
|
|
|
|
proc->waitForFinished();
|
|
|
|
proc->deleteLater();
|
|
|
|
|
2021-12-18 14:55:32 -08:00
|
|
|
// Restarting USBNet
|
2021-09-26 19:05:45 -07:00
|
|
|
// NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet)
|
2021-09-26 13:46:25 -07:00
|
|
|
string_writeconfig("/opt/ibxd", "usbnet_start\n");
|
2021-09-26 19:05:45 -07:00
|
|
|
QThread::msleep(1000);
|
2021-12-18 14:55:32 -08:00
|
|
|
// Mounting onboard storage
|
2021-09-26 13:46:25 -07:00
|
|
|
string_writeconfig("/opt/ibxd", "onboard_mount\n");
|
2021-09-26 19:05:45 -07:00
|
|
|
QThread::msleep(1000);
|
2021-12-18 14:55:32 -08:00
|
|
|
// Checking for updates
|
2021-12-18 21:28:47 -08:00
|
|
|
string_writeconfig("/opt/ibxd", "update_inkbox_restart\n");
|
2021-12-18 14:55:32 -08:00
|
|
|
QThread::msleep(2500);
|
2021-09-26 13:46:25 -07:00
|
|
|
|
|
|
|
quit_restart();
|
|
|
|
}
|
2021-05-09 11:07:05 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
usbms_t->start();
|
2021-03-25 05:00:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
usbms_splash::~usbms_splash()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2021-06-29 12:28:54 -07:00
|
|
|
|
|
|
|
void usbms_splash::brightnessDown() {
|
|
|
|
cinematicBrightness(0, 1);
|
|
|
|
}
|
2021-09-26 13:46:25 -07:00
|
|
|
|
|
|
|
void usbms_splash::quit_restart() {
|
|
|
|
// If existing, cleaning bookconfig_mount mountpoint
|
|
|
|
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
|
|
|
|
|
|
|
|
// Restarting InkBox
|
|
|
|
QProcess process;
|
|
|
|
process.startDetached("inkbox", QStringList());
|
|
|
|
qApp->quit();
|
|
|
|
}
|