Improve logging; timezone fix

This commit is contained in:
Nicolas Mailloux 2022-04-15 20:27:58 -04:00
parent 698ee57585
commit 239ac55bd7
12 changed files with 56 additions and 4 deletions

View file

@ -39,6 +39,7 @@ alert::alert(QWidget *parent) :
ui->alertIconLabel->setPixmap(scaledPixmap);
signatureError = true;
log("Displaying signature error alert splash", className);
ui->securityLabel->setText("Failed to update InkBox.");
ui->messageLabel->setText("The digital signature of the update is untrusted.\nFor security reasons, it cannot be installed.");
ui->stackedWidget->setCurrentIndex(1);
@ -48,6 +49,7 @@ alert::alert(QWidget *parent) :
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->alertIconLabel->setPixmap(scaledPixmap);
log("Displaying downgrade error alert splash", className);
downgradeError = true;
ui->securityLabel->setText("Failed to update InkBox.");
ui->messageLabel->setText("An error occured during the update process.\nThe update package's version is lower than the actual installed version.");
@ -77,6 +79,7 @@ alert::alert(QWidget *parent) :
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->alertIconLabel->setPixmap(scaledPixmap);
log("Displaying critical battery alert splash", className);
criticalBattery = true;
ui->warningLabel->setText("Please charge your eReader.");
ui->securityLabel->setText("The battery's charge level is critical.");
@ -121,6 +124,7 @@ void alert::on_continueBtn_clicked()
void alert::on_resetBtn_clicked()
{
// We set the DO_FACTORY_RESET flag and we restart the Kobo
log("Factory reset requested; setting required flags", className);
string_writeconfig("/external_root/boot/flags/DO_FACTORY_RESET", "true");
string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true");
QString reboot_prog ("/sbin/reboot");
@ -138,6 +142,7 @@ void alert::on_continue2Btn_clicked()
string_writeconfig("/external_root/boot/flags/ALERT", "false");
updateReset();
log("Restarting InkBox", className);
if(signatureError == true) {
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
QProcess process;

View file

@ -176,9 +176,11 @@ void brightnessDialog::on_okBtn_clicked()
int warmthValue;
// Write brightness config
log("Display brightness set to " + QString::number(brightnessValue), className);
brightness_writeconfig(brightnessValue);
if(global::isN873 == true) {
warmthValue = ui->warmthSlider->value();
log("Display warmth set to " + QString::number(warmthValue), className);
warmth_writeconfig(warmthValue);
}

View file

@ -59,6 +59,7 @@ void dictionaryWidget::on_backBtn_clicked()
}
void dictionaryWidget::dictionaryLookup(std::string word, QString first_letter, int position) {
log("Dictionary lookup requested for word '" + QString::fromStdString(word) + "', position " + QString::number(position), className);
QDir dictdir;
dictdir.mkpath("/inkbox/dictionary");

View file

@ -118,6 +118,7 @@ void encryptionManager::setupPassphraseDialog() {
* 1: Normal behavior
* 2: Repack
*/
log("Showing passphrase dialog for mode " + QString::number(setupPassphraseDialogMode), className);
ui->activityWidget->hide();
this->setStyleSheet("background-color: black");
global::keyboard::keyboardDialog = true;
@ -142,12 +143,14 @@ void encryptionManager::setupPassphraseDialog() {
void encryptionManager::on_setupAbortBtn_clicked()
{
log("Aborting setup", className);
setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/status", "false");
quit_restart();
}
void encryptionManager::quit_restart() {
log("Restarting InkBox", className);
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
@ -166,6 +169,7 @@ void encryptionManager::showToast(QString messageToDisplay) {
}
void encryptionManager::setupEncryptedStorage() {
log("Setting up encrypted storage", className);
this->setStyleSheet("background-color: white");
ui->activityWidget->show();
if(global::encfs::cancelSetup == true) {
@ -199,6 +203,7 @@ void encryptionManager::setupEncryptedStorage() {
}
void encryptionManager::unlockEncryptedStorage() {
log("Trying to unlock encrypted storage", className);
if(global::encfs::cancelSetup == true) {
global::encfs::cancelSetup = false;
poweroff(true);
@ -233,6 +238,7 @@ void encryptionManager::unlockEncryptedStorage() {
if(QFile::exists("/external_root/run/encfs_mounted")) {
exitStatus = checkconfig("/external_root/run/encfs_mounted");
if(exitStatus == false) {
QString function = __func__; log(function + ": Invalid passphrase", className);
if(setupMessageBoxRan == false) {
int delay = 0;
if(passphraseTries <= 3) {
@ -281,6 +287,7 @@ void encryptionManager::unlockEncryptedStorage() {
}
void encryptionManager::mkEncfsDirs() {
log("Creating encrypted storage directories", className);
QDir encfsDir;
QString encfsPath("/external_root/run/encfs");
encfsDir.mkpath(encfsPath);
@ -320,6 +327,7 @@ void encryptionManager::on_failureContinueBtn_clicked()
}
void encryptionManager::setupFailedAuthenticationMessageBox() {
log("Showing 'Authentication failed' message box", className);
ui->activityWidget->hide();
QMessageBox::critical(this, tr("Invalid argument"), tr("<font face='u001'>Invalid passphrase. Please try again.</font>"));
QFile::remove("/external_root/run/encfs_mounted");
@ -335,6 +343,7 @@ void encryptionManager::on_acceptBtn_clicked()
void encryptionManager::on_usbmsBtn_clicked()
{
log("Showing USBMS splash", className);
global::usbms::launchUsbms = true;
usbmsWindow = new usbms_splash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
@ -343,6 +352,7 @@ void encryptionManager::on_usbmsBtn_clicked()
}
void encryptionManager::repackEncryptedStorage() {
log("Repacking encrypted storage", className);
if(global::encfs::cancelSetup == true) {
global::encfs::cancelSetup = false;
quit_restart();

View file

@ -691,6 +691,7 @@ namespace {
string_writeconfig(sysfsWarmthPath, warmthValueStr);
}
void installUpdate() {
log("Installing update package", "functions");
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true");
string_writeconfig("/external_root/opt/update/will_update", "true");
string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true");

View file

@ -206,6 +206,7 @@ generalDialog::~generalDialog()
void generalDialog::on_cancelBtn_clicked()
{
log("Cancel button clicked", className);
if(updateDialog == true) {
string_writeconfig("/tmp/cancelUpdateDialog", "true");
generalDialog::close();
@ -253,10 +254,12 @@ void generalDialog::on_cancelBtn_clicked()
void generalDialog::on_okBtn_clicked()
{
log("OK button clicked", className);
if(resetDialog == true) {
if(checkconfig("/opt/inkbox_genuine") == true) {
// Soft-reset the device
// We set a custom boot flag and reboot silently in Diagnostics
log("Setting up the device for soft-reset", className);
string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true");
string_writeconfig("/external_root/boot/flags/DO_SOFT_RESET", "true");
reboot(false);
@ -264,6 +267,7 @@ void generalDialog::on_okBtn_clicked()
}
else {
// Restore default settings, we're not on InkBox OS
log("Restoring default settings", className);
QString prog ("sh");
QStringList args;
args << "reset-config.sh";
@ -297,6 +301,7 @@ void generalDialog::on_okBtn_clicked()
}
}
if(usbmsDialog == true) {
log("Showing USBMS splash", className);
global::usbms::usbmsDialog = false;
global::usbms::launchUsbms = true;
@ -343,6 +348,7 @@ void generalDialog::on_okBtn_clicked()
onboardPath = "/mnt/onboard/";
}
QDirIterator dirIt(onboardPath, QDirIterator::Subdirectories);
log("Searching local storage for '" + global::keyboard::keyboardText + "'", className);
while(dirIt.hasNext()) {
dirIt.next();
if(QFileInfo(dirIt.filePath()).isFile()) {
@ -356,6 +362,7 @@ void generalDialog::on_okBtn_clicked()
}
}
if(!storageSearchResults.isEmpty()) {
log("Displaying search results", className);
for(int i = ui->mainStackedWidget->count(); i >= 0; i--) {
QWidget * widget = ui->mainStackedWidget->widget(i);
ui->mainStackedWidget->removeWidget(widget);
@ -372,6 +379,7 @@ void generalDialog::on_okBtn_clicked()
ui->mainStackedWidget->insertWidget(1, searchResultsWidgetWindow);
}
else {
log("No search results found", className);
global::toast::delay = 3000;
emit showToast("No results found");
keyboardWidget->clearLineEdit();
@ -381,6 +389,7 @@ void generalDialog::on_okBtn_clicked()
else if(ui->searchComboBox->currentText() == "Online library") {
if(testPing() == 0 or global::deviceID == "emu\n") {
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
log("Searching online library for '" + global::keyboard::keyboardText + "'", className);
if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) {
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
@ -426,6 +435,7 @@ void generalDialog::on_okBtn_clicked()
}
else if(global::keyboard::vncDialog == true) {
if(!global::keyboard::keyboardText.isEmpty()) {
log("Gathering VNC connection information", className);
if(vncServerSet != true) {
vncServerAddress = global::keyboard::keyboardText;
vncServerSet = true;
@ -453,6 +463,7 @@ void generalDialog::on_okBtn_clicked()
}
else if(global::keyboard::wifiPassphraseDialog == true) {
if(!global::keyboard::keyboardText.isEmpty()) {
log("Attempting connection to Wi-Fi network '" + wifiEssid + "'", className);
this->hide();
wifiPassphrase = global::keyboard::keyboardText;
global::toast::indefiniteToast = true;
@ -492,12 +503,14 @@ void generalDialog::on_okBtn_clicked()
}
if(global::encfs::repackDialog == true) {
global::encfs::repackDialog = false;
log("Encrypted storage repack requested", className);
string_writeconfig("/external_root/run/encfs_repack", "true");
quit_restart();
}
}
void generalDialog::on_acceptBtn_clicked()
{
log("OK button clicked", className);
if(lowBatteryDialog == true) {
global::mainwindow::lowBatteryDialog = false;
global::battery::batteryAlertLock = false;
@ -579,6 +592,7 @@ void generalDialog::refreshScreenNative() {
}
void generalDialog::startVNC(QString server, QString password, QString port) {
log("Launching VNC viewer", className);
std::string server_str = server.toStdString();
std::string password_str = password.toStdString();
std::string port_str = port.toStdString();
@ -630,6 +644,7 @@ void generalDialog::closeIndefiniteToastNative() {
}
void generalDialog::quit_restart() {
log("Restarting InkBox", className);
// If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
@ -640,6 +655,7 @@ void generalDialog::quit_restart() {
}
void generalDialog::syncGutenbergCatalog() {
log("Syncing Gutenberg catalog", className);
global::toast::modalToast = true;
global::toast::indefiniteToast = true;
emit showToast("Sync in progress");

View file

@ -123,10 +123,12 @@ void koboxAppsDialog::on_launchBtn_clicked()
dpModeSetting = "windowed";
if(itemText == "Netsurf") {
log("Launching KoBox app: NetSurf", className);
// Bypass standard shell script launch shenanigans
string_writeconfig("/external_root/tmp/X_program", "!netsurf");
}
else if(itemText == "KTerm") {
log("Launching KoBox app: KTerm", className);
string_writeconfig("/external_root/tmp/X_program", "/usr/local/bin/kterm -l /usr/local/share/kterm/layouts/keyboard-kt.xml -k 1");
dpModeSetting = "fullscreen";
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
@ -146,9 +148,11 @@ void koboxAppsDialog::on_launchBtn_clicked()
}
}
else if(itemText == "Geany") {
log("Launching KoBox app: Geany", className);
string_writeconfig("/external_root/tmp/X_program", "geany");
}
else {
log("Launching KoBox app: " + itemText, className);
QString itemTextLower = itemText.toLower();
std::string app = itemTextLower.toStdString();
string_writeconfig("/external_root/tmp/X_program", app);
@ -161,6 +165,7 @@ void koboxAppsDialog::on_launchBtn_clicked()
global::kobox::showKoboxSplash = true;
// Re-use USBMS splash window for KoBox splash, since it's pretty much the same layout
log("Showing USBMS splash", className);
usbmsSplashWindow = new usbms_splash();
usbmsSplashWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsSplashWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry().size()));

View file

@ -80,6 +80,7 @@ void koboxSettings::on_checkBox_toggled(bool checked)
{
if(checked == true) {
if(not_user_change != true) {
log("Enabling KoBox subsystem", className);
string_writeconfig("/external_root/boot/flags/X11_START", "true");
openSettingsRebootDialog();
}
@ -88,6 +89,7 @@ void koboxSettings::on_checkBox_toggled(bool checked)
}
}
else {
log("Disabling KoBox subsystem", className);
string_writeconfig("/external_root/boot/flags/X11_START", "false");
openSettingsRebootDialog();
}
@ -110,6 +112,7 @@ void koboxSettings::on_spinBox_valueChanged(int arg1)
QString number = QString::number(arg1);
string number_str = number.toStdString();
string_writeconfig(".config/00-kobox/dpiSetting", number_str);
log("X11 DPI set to " + number, className);
}
void koboxSettings::on_pushButton_clicked()
@ -119,6 +122,8 @@ void koboxSettings::on_pushButton_clicked()
global::usbms::launchUsbms = true;
global::usbms::koboxExportExtensions = true;
log("Exporting KoBox extensions onboard storage via USB", className);
log("Showing USBMS splash", className);
usbmsWindow = new usbms_splash();
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));

View file

@ -49,6 +49,7 @@ int main(int argc, char *argv[])
return a.exec();
}
else if(checkconfig("/external_root/run/encfs_mounted") == true and checkconfig("/external_root/run/encfs_repack") == true) {
log("Launching encryptionManager", "main");
QApplication a(argc, argv);
encryptionManager w;
const QScreen * screen = qApp->primaryScreen();

View file

@ -949,6 +949,7 @@ bool reader::epub_file_match(QString file) {
}
void reader::dictionary_lookup(string word, QString first_letter, int position) {
log("Dictionary lookup requested for word '" + QString::fromStdString(word) + "', position " + QString::number(position), className);
ofstream fhandler;
fhandler.open("/inkbox/dictionary/word");
fhandler << word;

View file

@ -55,7 +55,7 @@ settings::settings(QWidget *parent) :
ui->generateSystemReportBtn->setStyleSheet("font-size: 9pt");
ui->checkOtaUpdateBtn->setStyleSheet("font-size: 9pt");
ui->comboBox->setStyleSheet("font-size: 9pt");
ui->tzComboBox->setStyleSheet("font-size: 8.5pt");
ui->tzComboBox->setStyleSheet("font-size: 9pt");
ui->sleepTimeoutComboBox->setStyleSheet("font-size: 9pt");
ui->setPasscodeBtn->setStyleSheet("font-size: 9pt");
ui->repackBtn->setStyleSheet("font-size: 9pt");
@ -952,6 +952,7 @@ void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked)
}
void settings::disableStorageEncryption() {
log("Disabling encrypted storage", className);
setDefaultWorkDir();
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true");
string_writeconfig("/opt/ibxd", "encfs_stop\n");
@ -993,6 +994,7 @@ void settings::on_repackBtn_clicked()
void settings::on_generateSystemReportBtn_clicked()
{
log("Generating system report", className);
string_writeconfig("/opt/ibxd", "generate_system_report\n");
while(true) {
if(QFile::exists("/inkbox/systemReportDone")) {
@ -1014,11 +1016,14 @@ void settings::on_tzComboBox_currentTextChanged(const QString &arg1)
timezone_not_user_change = false;
}
else {
log("Setting timezone to " + arg1, className);
setDefaultWorkDir();
// Preventing unnecessary (e)MMC writes
if(readFile(".config/19-timezone/config-name") != arg1) {
QProcess::execute("ln", QStringList() << "-sf" << "/usr/share/zoneinfo/" + arg1 << ".config/19-timezone/config");
string_writeconfig(".config/19-timezone/config-name", arg1.toStdString());
string_writeconfig("/opt/ibxd", "gui_remount_localtime\n");
QThread::msleep(500);
}
}
}

View file

@ -48,8 +48,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>463</width>
<height>632</height>
<width>457</width>
<height>657</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -1054,7 +1054,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Timezone (reboot req.)</string>
<string>Timezone</string>
</property>
</widget>
</item>