Remove some deprecated functions

This commit is contained in:
Nicolas Mailloux 2023-07-11 09:22:48 -04:00
parent 9da168fc7e
commit 11c8c90548
19 changed files with 354 additions and 455 deletions

View file

@ -145,7 +145,7 @@ void encryptionManager::on_setupAbortBtn_clicked()
{ {
log("Aborting setup", className); log("Aborting setup", className);
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/status", "false"); writeFile(".config/18-encrypted_storage/status", "false");
quit_restart(); quit_restart();
} }
@ -178,15 +178,15 @@ void encryptionManager::setupEncryptedStorage() {
} }
else { else {
mkEncfsDirs(); mkEncfsDirs();
std::string bootstrapPassphrase = global::encfs::passphrase.toStdString(); QString bootstrapPassphrase = global::encfs::passphrase;
global::encfs::passphrase = ""; global::encfs::passphrase = "";
string_writeconfig("/external_root/run/encfs/encrypted_storage_create", "true"); writeFile("/external_root/run/encfs/encrypted_storage_create", "true");
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox"); writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs"); writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase); writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted"); writeFile(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
string_writeconfig("/opt/ibxd", "encfs_restart\n"); writeFile("/opt/ibxd", "encfs_restart\n");
bool exitStatus; bool exitStatus;
ui->activityWidget->setCurrentIndex(3); ui->activityWidget->setCurrentIndex(3);
QTimer * t = new QTimer(this); QTimer * t = new QTimer(this);
@ -213,21 +213,21 @@ void encryptionManager::unlockEncryptedStorage() {
this->setStyleSheet("background-color: white"); this->setStyleSheet("background-color: white");
ui->activityWidget->show(); ui->activityWidget->show();
mkEncfsDirs(); mkEncfsDirs();
std::string passphrase = global::encfs::passphrase.toStdString(); QString passphrase = global::encfs::passphrase;
global::encfs::passphrase = ""; global::encfs::passphrase = "";
string_writeconfig("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs"); writeFile("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs");
string_writeconfig("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/encfs-decrypted"); writeFile("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/encfs-decrypted");
string_writeconfig("/external_root/run/encfs/encrypted_storage_bindmount", "/kobo/mnt/onboard/onboard/encfs-decrypted"); writeFile("/external_root/run/encfs/encrypted_storage_bindmount", "/kobo/mnt/onboard/onboard/encfs-decrypted");
string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase); writeFile("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
string_writeconfig("/opt/ibxd", "encfs_restart\n"); writeFile("/opt/ibxd", "encfs_restart\n");
bool exitStatus; bool exitStatus;
string_checkconfig_ro("/inkbox/encryptedStoragePassphraseTries"); QString passphraseTriesStr = readFile("/inkbox/encryptedStoragePassphraseTries");
if(checkconfig_str_val.isEmpty()) { if(passphraseTriesStr.isEmpty()) {
passphraseTries = 0; passphraseTries = 0;
} }
else { else {
passphraseTries = checkconfig_str_val.toInt(); passphraseTries = passphraseTriesStr.toInt();
passphraseTries++; passphraseTries++;
} }
@ -245,19 +245,19 @@ void encryptionManager::unlockEncryptedStorage() {
int delay = 0; int delay = 0;
if(passphraseTries <= 3) { if(passphraseTries <= 3) {
if(passphraseTries == 0) { if(passphraseTries == 0) {
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "0"); writeFile("/inkbox/encryptedStoragePassphraseTries", "0");
delay = 5000; delay = 5000;
} }
else if(passphraseTries == 1) { else if(passphraseTries == 1) {
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "1"); writeFile("/inkbox/encryptedStoragePassphraseTries", "1");
delay = 10000; delay = 10000;
} }
else if(passphraseTries == 2) { else if(passphraseTries == 2) {
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "2"); writeFile("/inkbox/encryptedStoragePassphraseTries", "2");
delay = 20000; delay = 20000;
} }
else if(passphraseTries >= 3) { else if(passphraseTries >= 3) {
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "3"); writeFile("/inkbox/encryptedStoragePassphraseTries", "3");
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch(); unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
currentEpoch += 86400; currentEpoch += 86400;
QString unlockTime_str = QString::number(currentEpoch); QString unlockTime_str = QString::number(currentEpoch);
@ -305,7 +305,7 @@ void encryptionManager::mkEncfsDirs() {
void encryptionManager::on_exitSuccessBtn_clicked() void encryptionManager::on_exitSuccessBtn_clicked()
{ {
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "true"); writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
quit_restart(); quit_restart();
} }
@ -315,7 +315,7 @@ void encryptionManager::setupExitWidget(bool exitStatus) {
ui->activityWidget->setCurrentIndex(1); ui->activityWidget->setCurrentIndex(1);
} }
else { else {
string_writeconfig(".config/18-encrypted_storage/status", "false"); writeFile(".config/18-encrypted_storage/status", "false");
ui->activityWidget->setCurrentIndex(2); ui->activityWidget->setCurrentIndex(2);
} }
setupExitWidgetRan = true; setupExitWidgetRan = true;
@ -325,7 +325,7 @@ void encryptionManager::setupExitWidget(bool exitStatus) {
void encryptionManager::on_failureContinueBtn_clicked() void encryptionManager::on_failureContinueBtn_clicked()
{ {
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "true"); writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
quit_restart(); quit_restart();
} }
@ -338,7 +338,7 @@ void encryptionManager::setupFailedAuthenticationMessageBox() {
void encryptionManager::on_acceptBtn_clicked() void encryptionManager::on_acceptBtn_clicked()
{ {
string_writeconfig(".config/18-encrypted_storage/status", "false"); writeFile(".config/18-encrypted_storage/status", "false");
quit_restart(); quit_restart();
} }
@ -363,11 +363,11 @@ void encryptionManager::repackEncryptedStorage() {
this->setStyleSheet("background-color: white"); this->setStyleSheet("background-color: white");
ui->activityWidget->show(); ui->activityWidget->show();
mkEncfsDirs(); mkEncfsDirs();
std::string passphrase = global::encfs::passphrase.toStdString(); QString passphrase = global::encfs::passphrase;
global::encfs::passphrase = ""; global::encfs::passphrase = "";
string_writeconfig("/external_root/run/encfs/encrypted_storage_repack_passphrase", passphrase); writeFile("/external_root/run/encfs/encrypted_storage_repack_passphrase", passphrase);
QFile::remove("/external_root/run/openrc/started/encfs"); QFile::remove("/external_root/run/openrc/started/encfs");
string_writeconfig("/opt/ibxd", "encfs_restart\n"); writeFile("/opt/ibxd", "encfs_restart\n");
bool exitStatus; bool exitStatus;
ui->activityWidget->setCurrentIndex(3); ui->activityWidget->setCurrentIndex(3);
QTimer * t = new QTimer(this); QTimer * t = new QTimer(this);

View file

@ -212,7 +212,6 @@ namespace global {
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534 // https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
namespace { namespace {
QString checkconfig_str_val;
QString deviceUID; QString deviceUID;
QString device; QString device;
QString batt_level; QString batt_level;
@ -275,37 +274,17 @@ namespace {
} }
return 0; return 0;
}; };
bool checkconfig_rw(QString file) {
if(QFile::exists(file)) {
QFile config(file);
config.open(QIODevice::ReadWrite);
QTextStream in (&config);
const QString content = in.readAll();
std::string contentstr = content.toStdString();
config.close();
if(contentstr.find("true") != std::string::npos) {
return true;
}
else {
return false;
}
}
else {
return false;
}
return 0;
};
void setDefaultWorkDir() { void setDefaultWorkDir() {
QDir::setCurrent("/mnt/onboard/.adds/inkbox"); QDir::setCurrent("/mnt/onboard/.adds/inkbox");
} }
int brightness_checkconfig(QString file) { int brightnessCheckconfig(QString file) {
if(QFile::exists(file)) { if(QFile::exists(file)) {
QFile config(file); QFile config(file);
config.open(QIODevice::ReadWrite); config.open(QIODevice::ReadWrite);
QTextStream in (&config); QTextStream in (&config);
const QString content = in.readAll(); const QString content = in.readAll();
int content_int = content.toInt(); int contentInt = content.toInt();
return content_int; return contentInt;
config.close(); config.close();
} }
else { else {
@ -313,7 +292,7 @@ namespace {
} }
return 0; return 0;
} }
void set_brightness(int value) { void setBrightness(int value) {
if(QFile::exists("/var/run/brightness")) { if(QFile::exists("/var/run/brightness")) {
std::ofstream fhandler; std::ofstream fhandler;
fhandler.open("/var/run/brightness"); fhandler.open("/var/run/brightness");
@ -321,33 +300,18 @@ namespace {
fhandler.close(); fhandler.close();
} }
} }
void set_brightness_ntxio(int value) { void setBrightness_ntxio(int value) {
// Thanks to Kevin Short for this (GloLight) // Thanks to Kevin Short for this (GloLight)
int light; int light;
if((light = open("/dev/ntx_io", O_RDWR)) == -1) { if((light = open("/dev/ntx_io", O_RDWR)) == -1) {
fprintf(stderr, "Error opening ntx_io device\n"); fprintf(stderr, "Error opening ntx_io device\n");
} }
ioctl(light, 241, value); ioctl(light, 241, value);
close(light); close(light);
} }
int int_checkconfig(QString file) { int displayQuote() {
if(QFile::exists(file)) {
QFile int_config(file);
int_config.open(QIODevice::ReadOnly);
QString valuestr = int_config.readAll();
int value = valuestr.toInt();
int_config.close();
return value;
}
else {
return EXIT_FAILURE;
}
return 0;
}
int display_quote() {
int quoteNumber = QRandomGenerator::global()->bounded(1, 6); int quoteNumber = QRandomGenerator::global()->bounded(1, 6);
return quoteNumber; return quoteNumber;
return 0;
} }
bool writeFile(QString filename, QString content) { bool writeFile(QString filename, QString content) {
QFile file(filename); QFile file(filename);
@ -361,38 +325,6 @@ namespace {
return false; return false;
} }
} }
void string_writeconfig(std::string file, std::string config_option) {
std::ofstream fhandler;
fhandler.open(file);
fhandler << config_option;
fhandler.close();
}
void string_checkconfig(QString file) {
if(QFile::exists(file)) {
checkconfig_str_val = "";
QFile config(file);
config.open(QIODevice::ReadWrite);
QTextStream in (&config);
checkconfig_str_val = in.readAll();
config.close();
}
else {
checkconfig_str_val = "";
}
}
void string_checkconfig_ro(QString file) {
if(QFile::exists(file)) {
checkconfig_str_val = "";
QFile config(file);
config.open(QIODevice::ReadOnly);
QTextStream in (&config);
checkconfig_str_val = in.readAll();
config.close();
}
else {
checkconfig_str_val = "";
}
}
QString readFile(QString file) { QString readFile(QString file) {
if(QFile::exists(file)) { if(QFile::exists(file)) {
QFile fileToRead(file); QFile fileToRead(file);
@ -405,27 +337,27 @@ namespace {
return NULL; return NULL;
} }
} }
void brightness_writeconfig(int value) { void brightnessWriteconfig(int value) {
std::ofstream fhandler; std::ofstream fhandler;
fhandler.open(".config/03-brightness/config"); fhandler.open(".config/03-brightness/config");
fhandler << value; fhandler << value;
fhandler.close(); fhandler.close();
} }
void warmth_writeconfig(int value) { void warmthWriteconfig(int value) {
std::ofstream fhandler; std::ofstream fhandler;
fhandler.open(".config/03-brightness/config-warmth"); fhandler.open(".config/03-brightness/config-warmth");
fhandler << value; fhandler << value;
fhandler.close(); fhandler.close();
} }
int get_brightness() { int getBrightness() {
if(global::deviceID == "n613\n") { if(global::deviceID == "n613\n") {
string_checkconfig_ro(".config/03-brightness/config"); QString brightnessConfig = readFile(".config/03-brightness/config");
int brightness; int brightness;
if(checkconfig_str_val == "") { if(brightnessConfig.isEmpty()) {
brightness = 0; brightness = 0;
} }
else { else {
brightness = checkconfig_str_val.toInt(); brightness = brightnessConfig.toInt();
} }
return brightness; return brightness;
} }
@ -444,7 +376,7 @@ namespace {
} }
return 0; return 0;
} }
void get_battery_level() { void getBatteryLevel() {
QString batteryLevelFileQstr; QString batteryLevelFileQstr;
if(global::deviceID == "kt\n") { if(global::deviceID == "kt\n") {
QFile batt_level_file("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity"); QFile batt_level_file("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity");
@ -501,7 +433,7 @@ namespace {
}; };
bool isBatteryLow() { bool isBatteryLow() {
// Checks if battery level is under 15% of total capacity. // Checks if battery level is under 15% of total capacity.
get_battery_level(); getBatteryLevel();
if(batt_level_int <= 15) { if(batt_level_int <= 15) {
return true; return true;
} }
@ -512,7 +444,7 @@ namespace {
} }
bool isBatteryCritical() { bool isBatteryCritical() {
// Checks if the battery level is critical (i.e. <= 5%) // Checks if the battery level is critical (i.e. <= 5%)
get_battery_level(); getBatteryLevel();
if(batt_level_int <= 5) { if(batt_level_int <= 5) {
QString function = __func__; log(function + ": Battery is at a critical charge level!", "functions"); QString function = __func__; log(function + ": Battery is at a critical charge level!", "functions");
return true; return true;
@ -524,10 +456,10 @@ namespace {
} }
void zeroBrightness() { void zeroBrightness() {
if(global::deviceID != "n613\n") { if(global::deviceID != "n613\n") {
set_brightness(0); setBrightness(0);
} }
else { else {
set_brightness_ntxio(0); setBrightness_ntxio(0);
} }
} }
void poweroff(bool splash) { void poweroff(bool splash) {
@ -605,18 +537,16 @@ namespace {
proc->deleteLater(); proc->deleteLater();
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig("/external_root/run/initrd-fifo", "get_kernel_build_id\n"); writeFile("/external_root/run/initrd-fifo", "get_kernel_build_id\n");
QThread::msleep(100); QThread::msleep(100);
string_writeconfig("/external_root/run/initrd-fifo", "get_kernel_commit\n"); writeFile("/external_root/run/initrd-fifo", "get_kernel_commit\n");
QThread::msleep(100); QThread::msleep(100);
string_checkconfig_ro("/external_root/run/kernel_build_id"); QString kernelBuildID = readFile("/external_root/run/kernel_build_id").trimmed();
QString kernelBuildID = checkconfig_str_val.trimmed();
kernelVersion.append(", build "); kernelVersion.append(", build ");
kernelVersion.append(kernelBuildID); kernelVersion.append(kernelBuildID);
string_checkconfig_ro("/external_root/run/kernel_commit"); QString kernelCommit = readFile("/external_root/run/kernel_commit").trimmed();
QString kernelCommit = checkconfig_str_val.trimmed();
kernelVersion.append(", commit "); kernelVersion.append(", commit ");
kernelVersion.append(kernelCommit); kernelVersion.append(kernelCommit);
} }
@ -645,8 +575,7 @@ namespace {
getUID(); getUID();
getKernelVersion(); getKernelVersion();
global::systemInfoText = "<b>InkBox OS version "; global::systemInfoText = "<b>InkBox OS version ";
string_checkconfig_ro("/external_root/opt/isa/version"); global::systemInfoText.append(readFile("/external_root/opt/isa/version"));
global::systemInfoText.append(checkconfig_str_val);
global::systemInfoText.append("</b><br>Copyright <font face='Inter'>©</font> 2021-2023 Nicolas Mailloux and contributors<br>Special thanks to: Szybet, NiLuJe, akemnade, Rain92 (GitHub)"); global::systemInfoText.append("</b><br>Copyright <font face='Inter'>©</font> 2021-2023 Nicolas Mailloux and contributors<br>Special thanks to: Szybet, NiLuJe, akemnade, Rain92 (GitHub)");
global::systemInfoText.append("<br><b>GUI Git commit:</b> "); global::systemInfoText.append("<br><b>GUI Git commit:</b> ");
global::systemInfoText.append(GIT_VERSION); global::systemInfoText.append(GIT_VERSION);
@ -753,15 +682,15 @@ namespace {
log(function + "Defined default PDF page width to " + QString::number(defaultPdfPageWidth), "functions"); log(function + "Defined default PDF page width to " + QString::number(defaultPdfPageWidth), "functions");
} }
} }
void pre_set_brightness(int brightnessValue) { void preSetBrightness(int brightnessValue) {
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n873\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "kt\n") { if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n873\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "kt\n") {
set_brightness(brightnessValue); setBrightness(brightnessValue);
} }
else if(global::deviceID == "n613\n") { else if(global::deviceID == "n613\n") {
set_brightness_ntxio(brightnessValue); setBrightness_ntxio(brightnessValue);
} }
else { else {
set_brightness(brightnessValue); setBrightness(brightnessValue);
} }
} }
void cinematicBrightness(int value, int mode) { void cinematicBrightness(int value, int mode) {
@ -777,69 +706,69 @@ namespace {
int brightness = 0; int brightness = 0;
while(brightness != value) { while(brightness != value) {
brightness = brightness + 1; brightness = brightness + 1;
pre_set_brightness(brightness); preSetBrightness(brightness);
QThread::msleep(30); QThread::msleep(30);
} }
} }
else if(mode == 1) { else if(mode == 1) {
int brightness = get_brightness(); int brightness = getBrightness();
while(brightness != 0) { while(brightness != 0) {
brightness = brightness - 1; brightness = brightness - 1;
pre_set_brightness(brightness); preSetBrightness(brightness);
QThread::msleep(30); QThread::msleep(30);
} }
} }
else if(mode == 2) { else if(mode == 2) {
int brightness = get_brightness(); int brightness = getBrightness();
if(brightness <= value) { if(brightness <= value) {
while(brightness != value) { while(brightness != value) {
brightness = brightness + 1; brightness = brightness + 1;
pre_set_brightness(brightness); preSetBrightness(brightness);
QThread::msleep(30); QThread::msleep(30);
} }
} }
else if(brightness >= value) { else if(brightness >= value) {
while(brightness != value) { while(brightness != value) {
brightness = brightness - 1; brightness = brightness - 1;
pre_set_brightness(brightness); preSetBrightness(brightness);
QThread::msleep(30); QThread::msleep(30);
} }
} }
} }
} }
int get_warmth() { int getWarmth() {
QString sysfsWarmthPath; QString sysfsWarmthPath;
if(global::deviceID == "n873\n") { if(global::deviceID == "n873\n") {
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color"; sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
} }
string_checkconfig_ro(sysfsWarmthPath); QString warmthConfig = readFile(sysfsWarmthPath);
int warmthValue = checkconfig_str_val.toInt(); int warmthValue = warmthConfig.toInt();
warmthValue = 10 - warmthValue; warmthValue = 10 - warmthValue;
return warmthValue; return warmthValue;
} }
void set_warmth(int warmthValue) { void setWarmth(int warmthValue) {
// Value 0 gives a warmer lighting than value 10 // Value 0 gives a warmer lighting than value 10
warmthValue = 10 - warmthValue; warmthValue = 10 - warmthValue;
std::string warmthValueStr = std::to_string(warmthValue); QString warmthValueStr = QString::number(warmthValue);
std::string sysfsWarmthPath; QString sysfsWarmthPath;
if(global::deviceID == "n873\n") { if(global::deviceID == "n873\n") {
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color"; sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
} }
string_writeconfig(sysfsWarmthPath, warmthValueStr); writeFile(sysfsWarmthPath, warmthValueStr);
} }
void cinematicWarmth(int warmthValue) { void cinematicWarmth(int warmthValue) {
int currentWarmth = get_warmth(); int currentWarmth = getWarmth();
if(warmthValue < currentWarmth) { if(warmthValue < currentWarmth) {
while(warmthValue < currentWarmth) { while(warmthValue < currentWarmth) {
currentWarmth--; currentWarmth--;
set_warmth(currentWarmth); setWarmth(currentWarmth);
QThread::msleep(30); QThread::msleep(30);
} }
} }
else if(warmthValue > currentWarmth) { else if(warmthValue > currentWarmth) {
while(warmthValue > currentWarmth) { while(warmthValue > currentWarmth) {
currentWarmth++; currentWarmth++;
set_warmth(currentWarmth); setWarmth(currentWarmth);
QThread::msleep(30); QThread::msleep(30);
} }
} }
@ -848,7 +777,7 @@ namespace {
log("Installing update package", "functions"); log("Installing update package", "functions");
writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n"); writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n");
writeFile("/external_root/opt/update/will_update", "true\n"); writeFile("/external_root/opt/update/will_update", "true\n");
writeFile("/external_root/boot/flags/WILL_UPDATE", "true\n"); writeFile("/external_root/boot/flags/WILL_UPDATE", "true\n");
reboot(true); reboot(true);
} }
bool getEncFSStatus() { bool getEncFSStatus() {

View file

@ -187,10 +187,10 @@ MainWindow::MainWindow(QWidget *parent)
// Dark mode; write to the Kobo Nightmode FIFO // Dark mode; write to the Kobo Nightmode FIFO
if(checkconfig(".config/10-dark_mode/config") == true) { if(checkconfig(".config/10-dark_mode/config") == true) {
string_writeconfig("/tmp/invertScreen", "y"); writeFile("/tmp/invertScreen", "y");
} }
else { else {
string_writeconfig("/tmp/invertScreen", "n"); writeFile("/tmp/invertScreen", "n");
} }
// Clock setting to show seconds // Clock setting to show seconds
@ -199,7 +199,7 @@ MainWindow::MainWindow(QWidget *parent)
t->setInterval(500); t->setInterval(500);
connect(t, &QTimer::timeout, [&]() { connect(t, &QTimer::timeout, [&]() {
QString time = QTime::currentTime().toString("hh:mm:ss"); QString time = QTime::currentTime().toString("hh:mm:ss");
get_battery_level(); getBatteryLevel();
ui->timeLabel->setText(time); ui->timeLabel->setText(time);
ui->batteryLabel->setText(batt_level); ui->batteryLabel->setText(batt_level);
} ); } );
@ -210,7 +210,7 @@ MainWindow::MainWindow(QWidget *parent)
t->setInterval(500); t->setInterval(500);
connect(t, &QTimer::timeout, [&]() { connect(t, &QTimer::timeout, [&]() {
QString time = QTime::currentTime().toString("hh:mm"); QString time = QTime::currentTime().toString("hh:mm");
get_battery_level(); getBatteryLevel();
ui->timeLabel->setText(time); ui->timeLabel->setText(time);
ui->batteryLabel->setText(batt_level); ui->batteryLabel->setText(batt_level);
} ); } );
@ -272,8 +272,7 @@ MainWindow::MainWindow(QWidget *parent)
} }
// Global reading settings // Global reading settings
string_checkconfig(".config/16-global_reading_settings/config"); if(readFile(".config/16-global_reading_settings/config").isEmpty()) {
if(checkconfig_str_val == "") {
checked_box = false; checked_box = false;
writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings="); writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings=");
} }
@ -281,7 +280,7 @@ MainWindow::MainWindow(QWidget *parent)
if(checkconfig(".config/05-quote/config") == false) { if(checkconfig(".config/05-quote/config") == false) {
stdIconWidth = sW / 2; stdIconWidth = sW / 2;
stdIconHeight = sH / 2; stdIconHeight = sH / 2;
int quote_value = display_quote(); int quote_value = displayQuote();
if(quote_value == 1) { if(quote_value == 1) {
QPixmap pixmap(":/resources/chesterton.jpg"); QPixmap pixmap(":/resources/chesterton.jpg");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
@ -321,17 +320,17 @@ MainWindow::MainWindow(QWidget *parent)
// Check if it's the first boot since an update and confirm that it installed successfully // Check if it's the first boot since an update and confirm that it installed successfully
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) { if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
string_checkconfig_ro("/external_root/opt/isa/version"); QString version = readFile("/external_root/opt/isa/version");
QString updatemsg = "<font face='u001'>InkBox update to version "; QString updatemsg = "<font face='u001'>InkBox update to version ";
updatemsg = updatemsg.append(checkconfig_str_val); updatemsg = updatemsg.append(version);
updatemsg = updatemsg.remove(QRegExp("[\n]")); updatemsg = updatemsg.remove(QRegExp("[\n]"));
updatemsg = updatemsg.append(" completed successfully.<br><br>Changelog:<br>"); updatemsg = updatemsg.append(" completed successfully.<br><br>Changelog:<br>");
string_checkconfig_ro("/external_root/opt/isa/changelog"); QString changelog = readFile("/external_root/opt/isa/changelog");
updatemsg = updatemsg.append(checkconfig_str_val); updatemsg = updatemsg.append(changelog);
updatemsg = updatemsg.append("</font>"); updatemsg = updatemsg.append("</font>");
log("Showing update changelog", className); log("Showing update changelog", className);
QMessageBox::information(this, tr("Information"), updatemsg); QMessageBox::information(this, tr("Information"), updatemsg);
string_writeconfig("/external_root/opt/update/inkbox_updated", "false"); writeFile("/external_root/opt/update/inkbox_updated", "false");
// Trigger Gutenberg re-sync, because we deleted the .inkbox folder ;) // Trigger Gutenberg re-sync, because we deleted the .inkbox folder ;)
if(QFile::exists("/external_root/opt/storage/gutenberg/last_sync")) { if(QFile::exists("/external_root/opt/storage/gutenberg/last_sync")) {
@ -390,8 +389,7 @@ MainWindow::MainWindow(QWidget *parent)
// If the DEVKEY file is present, install a developer key // If the DEVKEY file is present, install a developer key
if(QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY") == true && QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY.dgst") == true) { if(QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY") == true && QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY.dgst") == true) {
string_checkconfig_ro("/mnt/onboard/onboard/.inkbox/DEVKEY"); QString developerKey = readFile("/mnt/onboard/onboard/.inkbox/DEVKEY").left(256);
QString developerKey = checkconfig_str_val.left(256);
setDefaultWorkDir(); setDefaultWorkDir();
QString prog ("sh"); QString prog ("sh");
@ -411,7 +409,7 @@ MainWindow::MainWindow(QWidget *parent)
// Write version control info to file in tmpfs // Write version control info to file in tmpfs
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
string_writeconfig("/external_root/run/inkbox_gui_git_commit", GIT_COMMIT); writeFile("/external_root/run/inkbox_gui_git_commit", GIT_COMMIT);
} }
} }
@ -424,7 +422,7 @@ void MainWindow::openUpdateDialog() {
log("Showing Update dialog", className); log("Showing Update dialog", className);
global::mainwindow::updateDialog = true; global::mainwindow::updateDialog = true;
// Write to a temporary file to show an "Update" prompt // Write to a temporary file to show an "Update" prompt
string_writeconfig("/inkbox/updateDialog", "true"); writeFile("/inkbox/updateDialog", "true");
// Setup the dialog // Setup the dialog
generalDialogWindow = new generalDialog(this); generalDialogWindow = new generalDialog(this);
@ -667,7 +665,7 @@ void MainWindow::setBatteryIcon() {
ui->batteryIcon->setPixmap(scaledChargingPixmap); ui->batteryIcon->setPixmap(scaledChargingPixmap);
} }
else { else {
get_battery_level(); getBatteryLevel();
if(batt_level_int >= 75 && batt_level_int <= 100) { if(batt_level_int >= 75 && batt_level_int <= 100) {
ui->batteryIcon->setPixmap(scaledFullPixmap); ui->batteryIcon->setPixmap(scaledFullPixmap);
} }
@ -697,7 +695,7 @@ void MainWindow::setBatteryIcon() {
ui->batteryIcon->setPixmap(scaledChargingPixmap); ui->batteryIcon->setPixmap(scaledChargingPixmap);
} }
else { else {
get_battery_level(); getBatteryLevel();
if(batt_level_int >= 75 && batt_level_int <= 100) { if(batt_level_int >= 75 && batt_level_int <= 100) {
ui->batteryIcon->setPixmap(scaledFullPixmap); ui->batteryIcon->setPixmap(scaledFullPixmap);
} }
@ -714,23 +712,23 @@ void MainWindow::setBatteryIcon() {
void MainWindow::setInitialBrightness() { void MainWindow::setInitialBrightness() {
if(global::deviceID == "n873\n") { if(global::deviceID == "n873\n") {
int warmth; int warmth;
string_checkconfig_ro(".config/03-brightness/config-warmth"); QString warmthConfig = readFile(".config/03-brightness/config-warmth");
if(checkconfig_str_val == "") { if(warmthConfig.isEmpty()) {
warmth = 0; warmth = 0;
} }
else { else {
warmth = checkconfig_str_val.toInt(); warmth = warmthConfig.toInt();
} }
cinematicWarmth(warmth); cinematicWarmth(warmth);
} }
int brightness_value = brightness_checkconfig(".config/03-brightness/config"); int brightness_value = brightnessCheckconfig(".config/03-brightness/config");
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") { if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
log("Setting initial brightness to " + QString::number(brightness_value), className); log("Setting initial brightness to " + QString::number(brightness_value), className);
} }
if(checkconfig("/tmp/oobe-inkbox_completed") == true) { if(checkconfig("/tmp/oobe-inkbox_completed") == true) {
// Coming from OOBE setup; not doing that fancy stuff again ;p // Coming from OOBE setup; not doing that fancy stuff again ;p
QFile::remove("/tmp/oobe-inkbox_completed"); QFile::remove("/tmp/oobe-inkbox_completed");
pre_set_brightness(brightness_value); preSetBrightness(brightness_value);
log("Ignoring cinematic brightness call because it has already been done", className); log("Ignoring cinematic brightness call because it has already been done", className);
} }
else { else {
@ -741,7 +739,7 @@ void MainWindow::setInitialBrightness() {
} }
else { else {
if(checkconfig("/tmp/inkbox-cinematicBrightness_ran") == false) { if(checkconfig("/tmp/inkbox-cinematicBrightness_ran") == false) {
string_writeconfig("/tmp/inkbox-cinematicBrightness_ran", "true"); writeFile("/tmp/inkbox-cinematicBrightness_ran", "true");
cinematicBrightness(brightness_value, 0); cinematicBrightness(brightness_value, 0);
} }
else { else {
@ -1023,10 +1021,10 @@ void MainWindow::resetFullWindow() {
void MainWindow::checkForOtaUpdate() { void MainWindow::checkForOtaUpdate() {
if(global::wifi::isConnected == true) { if(global::wifi::isConnected == true) {
string_checkconfig_ro("/external_root/opt/storage/update/last_sync"); QString lastSync = readFile("/external_root/opt/storage/update/last_sync");
if(!checkconfig_str_val.isEmpty()) { if(!lastSync.isEmpty()) {
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch(); unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
unsigned long syncEpoch = checkconfig_str_val.toULong(); unsigned long syncEpoch = lastSync.toULong();
unsigned long allowSyncEpoch = syncEpoch + 86400; unsigned long allowSyncEpoch = syncEpoch + 86400;
if(currentEpoch > allowSyncEpoch) { if(currentEpoch > allowSyncEpoch) {
launchOtaUpdater(); launchOtaUpdater();

View file

@ -46,7 +46,7 @@ int main(int argc, char *argv[])
log("Running on device " + global::deviceID, "main", true); log("Running on device " + global::deviceID, "main", true);
// Tell the OS that we're currently running // Tell the OS that we're currently running
string_writeconfig("/tmp/inkbox_running", "true"); writeFile("/tmp/inkbox_running", "true");
setDefaultWorkDir(); setDefaultWorkDir();
if(checkconfig("/run/wifi_able") == true) { if(checkconfig("/run/wifi_able") == true) {
@ -65,9 +65,9 @@ int main(int argc, char *argv[])
if(QFile::exists("/tmp/rescan_userapps")) { if(QFile::exists("/tmp/rescan_userapps")) {
QFile::remove("/tmp/rescan_userapps"); QFile::remove("/tmp/rescan_userapps");
log("Re-scanning user applications from explicit request", "main"); log("Re-scanning user applications from explicit request", "main");
string_writeconfig("/opt/ibxd", "gui_apps_stop\n"); writeFile("/opt/ibxd", "gui_apps_stop\n");
QThread::msleep(1000); QThread::msleep(1000);
string_writeconfig("/opt/ibxd", "gui_apps_start\n"); writeFile("/opt/ibxd", "gui_apps_start\n");
while(true) { while(true) {
if(QFile::exists("/tmp/gui_apps_started")) { if(QFile::exists("/tmp/gui_apps_started")) {
if(checkconfig("/tmp/gui_apps_started") == true) { if(checkconfig("/tmp/gui_apps_started") == true) {
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
global::reader::startUsbmsPrompt = true; global::reader::startUsbmsPrompt = true;
global::reader::skipOpenDialog = true; global::reader::skipOpenDialog = true;
string_writeconfig("/inkbox/skip_opendialog", "true"); writeFile("/inkbox/skip_opendialog", "true");
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
global::isN705 = true; global::isN705 = true;
} }

View file

@ -166,10 +166,10 @@ libraryWidget::libraryWidget(QWidget *parent) :
sH = QGuiApplication::screens()[0]->size().height(); sH = QGuiApplication::screens()[0]->size().height();
// Prevent abusive sync // Prevent abusive sync
string_checkconfig_ro("/external_root/opt/storage/gutenberg/last_sync"); QString lastSync = readFile("/external_root/opt/storage/gutenberg/last_sync");
if(!checkconfig_str_val.isEmpty()) { if(!lastSync.isEmpty()) {
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch(); unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
unsigned long syncEpoch = checkconfig_str_val.toULong(); unsigned long syncEpoch = lastSync.toULong();
unsigned long allowSyncEpoch = syncEpoch + 86400; unsigned long allowSyncEpoch = syncEpoch + 86400;
if(currentEpoch > allowSyncEpoch) { if(currentEpoch > allowSyncEpoch) {
syncCatalog(); syncCatalog();
@ -278,7 +278,7 @@ void libraryWidget::syncCatalog() {
void libraryWidget::syncCatalogSlot() { void libraryWidget::syncCatalogSlot() {
bool syncDone = false; bool syncDone = false;
string_writeconfig("/opt/ibxd", "gutenberg_sync\n"); writeFile("/opt/ibxd", "gutenberg_sync\n");
while(true) { while(true) {
if(syncDone == false) { if(syncDone == false) {
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) { if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {

View file

@ -14,7 +14,7 @@ otaManager::otaManager(QWidget *parent) :
QThread::msleep(500); QThread::msleep(500);
if(global::otaUpdate::downloadOta == false) { if(global::otaUpdate::downloadOta == false) {
log("Checking for available OTA update", className); log("Checking for available OTA update", className);
string_writeconfig("/opt/ibxd", "ota_update_check\n"); writeFile("/opt/ibxd", "ota_update_check\n");
QTimer * otaCheckTimer = new QTimer(this); QTimer * otaCheckTimer = new QTimer(this);
otaCheckTimer->setInterval(100); otaCheckTimer->setInterval(100);
connect(otaCheckTimer, &QTimer::timeout, [&]() { connect(otaCheckTimer, &QTimer::timeout, [&]() {
@ -28,7 +28,7 @@ otaManager::otaManager(QWidget *parent) :
emit canOtaUpdate(false); emit canOtaUpdate(false);
} }
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch(); unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
string_writeconfig("/external_root/opt/storage/update/last_sync", std::to_string(currentEpoch)); writeFile("/external_root/opt/storage/update/last_sync", QString::number(currentEpoch));
QFile::remove("/run/can_ota_update"); QFile::remove("/run/can_ota_update");
otaManager::close(); otaManager::close();
} }
@ -38,7 +38,7 @@ otaManager::otaManager(QWidget *parent) :
else { else {
log("Downloading OTA update", className); log("Downloading OTA update", className);
QFile::remove("/run/can_install_ota_update"); QFile::remove("/run/can_install_ota_update");
string_writeconfig("/opt/ibxd", "ota_update_download\n"); writeFile("/opt/ibxd", "ota_update_download\n");
QTimer * otaDownloadTimer = new QTimer(this); QTimer * otaDownloadTimer = new QTimer(this);
otaDownloadTimer->setInterval(100); otaDownloadTimer->setInterval(100);
connect(otaDownloadTimer, &QTimer::timeout, [&]() { connect(otaDownloadTimer, &QTimer::timeout, [&]() {

View file

@ -149,7 +149,7 @@ reader::reader(QWidget *parent) :
if(checkconfig("/tmp/suspendBook") == true) { if(checkconfig("/tmp/suspendBook") == true) {
wakeFromSleep = true; wakeFromSleep = true;
// Prevent from opening the Reader framework next time unless the condition is reset // Prevent from opening the Reader framework next time unless the condition is reset
string_writeconfig("/tmp/suspendBook", "false"); writeFile("/tmp/suspendBook", "false");
book_file = "/inkbox/book/book.txt"; book_file = "/inkbox/book/book.txt";
} }
else if(global::reader::bookFile.isEmpty() == false) { else if(global::reader::bookFile.isEmpty() == false) {
@ -219,14 +219,13 @@ reader::reader(QWidget *parent) :
log("Opening file '" + book_file + "'", className); log("Opening file '" + book_file + "'", className);
// Writing book path to file // Writing book path to file
std::string book_file_str = book_file.toStdString(); writeFile("/tmp/inkboxBookPath", book_file);
string_writeconfig("/tmp/inkboxBookPath", book_file_str);
// Calling InkBox daemon (ibxd) via FIFO interface to run bookconfig_mount // Calling InkBox daemon (ibxd) via FIFO interface to run bookconfig_mount
if(!book_file.isEmpty()) { if(!book_file.isEmpty()) {
if(checkconfig(".config/16-global_reading_settings/config") == false) { if(checkconfig(".config/16-global_reading_settings/config") == false) {
global::reader::globalReadingSettings = false; global::reader::globalReadingSettings = false;
string_writeconfig("/opt/ibxd", "bookconfig_mount\n"); writeFile("/opt/ibxd", "bookconfig_mount\n");
// Callback handler to wait until bookconfig_mount has finished execution // Callback handler to wait until bookconfig_mount has finished execution
while(true) { while(true) {
if(QFile::exists("/inkbox/bookConfigSetUp")) { if(QFile::exists("/inkbox/bookConfigSetUp")) {
@ -256,14 +255,14 @@ reader::reader(QWidget *parent) :
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n") { if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n") {
if(checkconfig(".config/10-dark_mode/config") == true) { if(checkconfig(".config/10-dark_mode/config") == true) {
log("Setting night mode to ON", className); log("Setting night mode to ON", className);
string_writeconfig("/tmp/invertScreen", "y"); writeFile("/tmp/invertScreen", "y");
ui->nightModeBtn->setText(""); ui->nightModeBtn->setText("");
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png")); ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png"));
isNightModeActive = true; isNightModeActive = true;
} }
else { else {
log("Setting night mode to OFF", className); log("Setting night mode to OFF", className);
string_writeconfig("/tmp/invertScreen", "n"); writeFile("/tmp/invertScreen", "n");
ui->nightModeBtn->setText(""); ui->nightModeBtn->setText("");
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png")); ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
isNightModeActive = false; isNightModeActive = false;
@ -375,25 +374,19 @@ reader::reader(QWidget *parent) :
} }
// Checking if there is a page refresh setting set // Checking if there is a page refresh setting set
string_checkconfig(".config/04-book/refresh"); if(readFile(".config/04-book/refresh").isEmpty()) {
if(checkconfig_str_val == "") {
// Writing the default, refresh every 3 pages // Writing the default, refresh every 3 pages
string_writeconfig(".config/04-book/refresh", "3"); writeFile(".config/04-book/refresh", "3");
string_checkconfig(".config/04-book/refresh");
} }
else { pageRefreshSetting = readFile(".config/04-book/refresh").toInt();
// A config option was set, continuing after the Else statement...
;
}
pageRefreshSetting = checkconfig_str_val.toInt();
// Checking if that config option was set to "Never refresh"... // Checking if that config option was set to "Never refresh"...
if(pageRefreshSetting == -1) { if(pageRefreshSetting == -1) {
log("Setting page refresh to 'disabled'", className); log("Setting page refresh to 'disabled'", className);
neverRefresh = true; neverRefresh = true;
} }
else { else {
log("Setting page refresh to each " + QString::number(pageRefreshSetting) + " pages", className);
// Safety measure // Safety measure
log("Setting page refresh to each " + checkconfig_str_val + " pages", className);
neverRefresh = false; neverRefresh = false;
} }
@ -403,7 +396,7 @@ reader::reader(QWidget *parent) :
t->setInterval(500); t->setInterval(500);
connect(t, &QTimer::timeout, [&]() { connect(t, &QTimer::timeout, [&]() {
QString time = QTime::currentTime().toString("hh:mm:ss"); QString time = QTime::currentTime().toString("hh:mm:ss");
get_battery_level(); getBatteryLevel();
ui->batteryLabel->setText(batt_level); ui->batteryLabel->setText(batt_level);
ui->timeLabel->setText(time); ui->timeLabel->setText(time);
} ); } );
@ -414,7 +407,7 @@ reader::reader(QWidget *parent) :
t->setInterval(500); t->setInterval(500);
connect(t, &QTimer::timeout, [&]() { connect(t, &QTimer::timeout, [&]() {
QString time = QTime::currentTime().toString("hh:mm"); QString time = QTime::currentTime().toString("hh:mm");
get_battery_level(); getBatteryLevel();
ui->batteryLabel->setText(batt_level); ui->batteryLabel->setText(batt_level);
ui->timeLabel->setText(time); ui->timeLabel->setText(time);
} ); } );
@ -424,7 +417,7 @@ reader::reader(QWidget *parent) :
// Checking if we're waking from sleep and have lockscreen enabled; if so, do nothing there because the book should already have been parsed // Checking if we're waking from sleep and have lockscreen enabled; if so, do nothing there because the book should already have been parsed
if(wakeFromSleep != true) { if(wakeFromSleep != true) {
// Remount tmpfs // Remount tmpfs
string_writeconfig("/inkbox/remount", "true"); writeFile("/inkbox/remount", "true");
// Counting number of parsed files // Counting number of parsed files
split_total = setup_book(book_file, 0, true); split_total = setup_book(book_file, 0, true);
@ -435,8 +428,7 @@ reader::reader(QWidget *parent) :
} }
else { else {
// Retrieve split_total from tmpfs // Retrieve split_total from tmpfs
string_checkconfig("/tmp/inkboxPageNumber"); split_total = readFile("/tmp/inkboxPageNumber").toInt();
split_total = checkconfig_str_val.toInt();
setup_book(book_file, 0, true); setup_book(book_file, 0, true);
} }
@ -444,9 +436,9 @@ reader::reader(QWidget *parent) :
if(is_epub == false && is_pdf == false && is_image == false) { if(is_epub == false && is_pdf == false && is_image == false) {
setDefaultWorkDir(); setDefaultWorkDir();
if(global::reader::globalReadingSettings == false) { if(global::reader::globalReadingSettings == false) {
string_checkconfig_ro(".config/A-page_number/config"); QString splitTotalPageNumber = readFile(".config/A-page_number/config");
if(checkconfig_str_val != "") { if(!splitTotalPageNumber.isEmpty()) {
split_total = checkconfig_str_val.toInt(); split_total = splitTotalPageNumber.toInt();
} }
} }
setup_book(book_file, split_total, true); setup_book(book_file, split_total, true);
@ -561,8 +553,7 @@ reader::reader(QWidget *parent) :
else { else {
QString bookReadRelativePath; QString bookReadRelativePath;
if(wakeFromSleep == true) { if(wakeFromSleep == true) {
string_checkconfig_ro("/tmp/inkboxBookPath"); bookReadRelativePath = readFile("/tmp/inkboxBookPath").split("/").last();
bookReadRelativePath = checkconfig_str_val.split("/").last();
} }
else { else {
bookReadRelativePath = book_file.split("/").last(); bookReadRelativePath = book_file.split("/").last();
@ -589,10 +580,10 @@ reader::reader(QWidget *parent) :
} }
// Clean up // Clean up
string_writeconfig("/inkbox/remount", "true"); writeFile("/inkbox/remount", "true");
// Way to tell shell scripts that we're in the Reader framework // Way to tell shell scripts that we're in the Reader framework
string_writeconfig("/tmp/inkboxReading", "true"); writeFile("/tmp/inkboxReading", "true");
// Maintain a 'Recent books' list // Maintain a 'Recent books' list
QJsonObject recentBooksObject; QJsonObject recentBooksObject;
@ -747,7 +738,7 @@ int reader::setup_book(QString book, int i, bool run_parser) {
remount = false; remount = false;
} }
else { else {
string_writeconfig("/inkbox/remount", "false"); writeFile("/inkbox/remount", "false");
QString mount_prog ("sh"); QString mount_prog ("sh");
QStringList mount_args; QStringList mount_args;
mount_args << "split.sh"; mount_args << "split.sh";
@ -791,8 +782,8 @@ int reader::setup_book(QString book, int i, bool run_parser) {
ui->line->deleteLater(); ui->line->deleteLater();
ui->line_3->deleteLater(); ui->line_3->deleteLater();
string_writeconfig("/tmp/inkboxImagePath", book.toStdString()); writeFile("/tmp/inkboxImagePath", book);
string_writeconfig("/opt/ibxd", "inkbox_convert_image\n"); writeFile("/opt/ibxd", "inkbox_convert_image\n");
while(true) { while(true) {
if(QFile::exists("/inkbox/convertImageDone")) { if(QFile::exists("/inkbox/convertImageDone")) {
@ -825,11 +816,10 @@ int reader::setup_book(QString book, int i, bool run_parser) {
// Checking whether or not the user has defined an option for the number of words per page; if not, then setting the default. // Checking whether or not the user has defined an option for the number of words per page; if not, then setting the default.
// NOTE: This is only for plain text files. // NOTE: This is only for plain text files.
setDefaultWorkDir(); setDefaultWorkDir();
string_checkconfig(".config/07-words_number/config"); if(readFile(".config/07-words_number/config").isEmpty()) {
if(checkconfig_str_val == "") { writeFile(".config/07-words_number/config", "100");
string_writeconfig(".config/07-words_number/config", "100");
string_checkconfig(".config/07-words_number/config");
} }
QString wordsNumberConfig = readFile(".config/07-words_number/config");
// Parsing file // Parsing file
if(is_epub == true) { if(is_epub == true) {
@ -867,7 +857,7 @@ int reader::setup_book(QString book, int i, bool run_parser) {
else { else {
QString parse_prog ("/mnt/onboard/.adds/inkbox/system/bin/split-txt"); QString parse_prog ("/mnt/onboard/.adds/inkbox/system/bin/split-txt");
QStringList parse_args; QStringList parse_args;
parse_args << checkconfig_str_val; parse_args << wordsNumberConfig;
QProcess * parse_proc = new QProcess(); QProcess * parse_proc = new QProcess();
parse_proc->start(parse_prog, parse_args); parse_proc->start(parse_prog, parse_args);
parse_proc->waitForFinished(); parse_proc->waitForFinished();
@ -919,11 +909,11 @@ bool reader::epub_file_match(QString file) {
if(fileExt == "epub" or fileExt == "EPUB") { if(fileExt == "epub" or fileExt == "EPUB") {
log("Book file format: ePUB", className); log("Book file format: ePUB", className);
string_writeconfig("/inkbox/bookIsEpub", "true"); writeFile("/inkbox/bookIsEpub", "true");
return true; return true;
} }
else { else {
string_writeconfig("/inkbox/bookIsEpub", "false"); writeFile("/inkbox/bookIsEpub", "false");
return false; return false;
} }
} }
@ -1166,11 +1156,11 @@ void reader::on_homeBtn_clicked()
{ {
log("Returning to Home screen", className); log("Returning to Home screen", className);
// We're leaving reading mode // We're leaving reading mode
string_writeconfig("/tmp/inkboxReading", "false"); writeFile("/tmp/inkboxReading", "false");
// Remount tmpfs // Remount tmpfs
string_writeconfig("/inkbox/remount", "true"); writeFile("/inkbox/remount", "true");
// Specify cinematic brightness mode // Specify cinematic brightness mode
string_writeconfig("/tmp/inkbox-cinematicBrightness_auto", "true"); writeFile("/tmp/inkbox-cinematicBrightness_auto", "true");
// Relaunching process // Relaunching process
quit_restart(); quit_restart();
@ -1188,7 +1178,7 @@ void reader::on_alignLeftBtn_clicked()
log("Setting text alignment to 'Left'", className); log("Setting text alignment to 'Left'", className);
global::reader::textAlignment = 0; global::reader::textAlignment = 0;
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize); setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
string_writeconfig(".config/04-book/alignment", "Left"); writeFile(".config/04-book/alignment", "Left");
} }
void reader::on_alignCenterBtn_clicked() void reader::on_alignCenterBtn_clicked()
@ -1196,7 +1186,7 @@ void reader::on_alignCenterBtn_clicked()
log("Setting text alignment to 'Center'", className); log("Setting text alignment to 'Center'", className);
global::reader::textAlignment = 1; global::reader::textAlignment = 1;
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize); setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
string_writeconfig(".config/04-book/alignment", "Center"); writeFile(".config/04-book/alignment", "Center");
} }
void reader::on_alignRightBtn_clicked() void reader::on_alignRightBtn_clicked()
@ -1204,7 +1194,7 @@ void reader::on_alignRightBtn_clicked()
log("Setting text alignment to 'Right'", className); log("Setting text alignment to 'Right'", className);
global::reader::textAlignment = 2; global::reader::textAlignment = 2;
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize); setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
string_writeconfig(".config/04-book/alignment", "Right"); writeFile(".config/04-book/alignment", "Right");
} }
void reader::on_alignJustifyBtn_clicked() void reader::on_alignJustifyBtn_clicked()
@ -1212,7 +1202,7 @@ void reader::on_alignJustifyBtn_clicked()
log("Setting text alignment to 'Justify'", className); log("Setting text alignment to 'Justify'", className);
global::reader::textAlignment = 3; global::reader::textAlignment = 3;
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize); setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
string_writeconfig(".config/04-book/alignment", "Justify"); writeFile(".config/04-book/alignment", "Justify");
} }
void reader::setTextProperties(int alignment, int lineSpacing, int margins, QString font, int fontSize) { void reader::setTextProperties(int alignment, int lineSpacing, int margins, QString font, int fontSize) {
@ -1369,7 +1359,7 @@ void reader::menubar_show() {
ui->batteryIconLabel->setPixmap(scaledChargingPixmap); ui->batteryIconLabel->setPixmap(scaledChargingPixmap);
} }
else { else {
get_battery_level(); getBatteryLevel();
if(batt_level_int >= 75 && batt_level_int <= 100) { if(batt_level_int >= 75 && batt_level_int <= 100) {
ui->batteryIconLabel->setPixmap(scaledFullPixmap); ui->batteryIconLabel->setPixmap(scaledFullPixmap);
} }
@ -1531,30 +1521,30 @@ void reader::on_sizeSlider_valueChanged(int value)
void reader::writeconfig_pagenumber(bool persistent) { void reader::writeconfig_pagenumber(bool persistent) {
// Saving the page number in tmpfs and in persistent storage if requested // Saving the page number in tmpfs and in persistent storage if requested
if(is_epub == true) { if(is_epub == true) {
std::string epubPageNumber_str = std::to_string(mupdf::epub::epubPageNumber); QString epubPageNumberStr = QString::number(mupdf::epub::epubPageNumber);
string_writeconfig("/tmp/inkboxPageNumber", epubPageNumber_str); writeFile("/tmp/inkboxPageNumber", epubPageNumberStr);
if(persistent == true) { if(persistent == true) {
log("Writing page number config for page '" + QString::number(mupdf::epub::epubPageNumber) + "'", className); log("Writing page number config for page '" + QString::number(mupdf::epub::epubPageNumber) + "'", className);
epubPageNumber_str.append("\n"); epubPageNumberStr.append("\n");
string_writeconfig(".config/A-page_number/config", epubPageNumber_str); writeFile(".config/A-page_number/config", epubPageNumberStr);
} }
} }
else if(is_pdf == true) { else if(is_pdf == true) {
std::string pdfPageNumber_str = std::to_string(mupdf::pdf::pdfPageNumber); QString pdfPageNumberStr = QString::number(mupdf::pdf::pdfPageNumber);
string_writeconfig("/tmp/inkboxPageNumber", pdfPageNumber_str); writeFile("/tmp/inkboxPageNumber", pdfPageNumberStr);
if(persistent == true) { if(persistent == true) {
log("Writing page number config for page '" + QString::number(mupdf::pdf::pdfPageNumber) + "'", className); log("Writing page number config for page '" + pdfPageNumberStr + "'", className);
pdfPageNumber_str.append("\n"); pdfPageNumberStr.append("\n");
string_writeconfig(".config/A-page_number/config", pdfPageNumber_str); writeFile(".config/A-page_number/config", pdfPageNumberStr);
} }
} }
else { else {
std::string split_total_str = std::to_string(split_total); QString splitTotalStr = QString::number(split_total);
string_writeconfig("/tmp/inkboxPageNumber", split_total_str); writeFile("/tmp/inkboxPageNumber", splitTotalStr);
if(persistent == true) { if(persistent == true) {
log("Writing page number config for split total '" + QString::number(split_total) + "'", className); log("Writing page number config for split total '" + splitTotalStr + "'", className);
split_total_str.append("\n"); splitTotalStr.append("\n");
string_writeconfig(".config/A-page_number/config", split_total_str); writeFile(".config/A-page_number/config", splitTotalStr);
} }
} }
} }
@ -1566,7 +1556,7 @@ void reader::quit_restart() {
saveReadingSettings(); saveReadingSettings();
// Cleaning bookconfig_mount mountpoint // Cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n"); writeFile("/opt/ibxd", "bookconfig_unmount\n");
// Restarting InkBox // Restarting InkBox
QProcess process; QProcess process;
@ -1636,8 +1626,7 @@ void reader::convertMuPdfVars(int fileType, bool convertAll) {
} }
if(global::reader::globalReadingSettings == false) { if(global::reader::globalReadingSettings == false) {
if(goToSavedPageDone == false) { if(goToSavedPageDone == false) {
string_checkconfig_ro(".config/A-page_number/config"); mupdf::pdf::pdfPageNumber = readFile(".config/A-page_number/config").toInt();
mupdf::pdf::pdfPageNumber = checkconfig_str_val.toInt();
goToSavedPageDone = true; goToSavedPageDone = true;
} }
} }
@ -1664,29 +1653,19 @@ void reader::setPageStyle(int fileType) {
// General page size // General page size
defineDefaultPageSize(0); defineDefaultPageSize(0);
string_checkconfig_ro(".config/13-epub_page_size/width"); if(readFile(".config/13-epub_page_size/width").isEmpty()) {
if(checkconfig_str_val != "") { QString pageWidth = QString::number(defaultEpubPageWidth);
; writeFile(".config/13-epub_page_size/width", pageWidth);
writeFile(".config/13-epub_page_size/set", "true");
} }
else { mupdf::epub::width = readFile(".config/13-epub_page_size/width").toInt();
std::string pageWidth = std::to_string(defaultEpubPageWidth);
string_writeconfig(".config/13-epub_page_size/width", pageWidth);
string_writeconfig(".config/13-epub_page_size/set", "true");
string_checkconfig_ro(".config/13-epub_page_size/width");
}
mupdf::epub::width = checkconfig_str_val.toInt();
string_checkconfig_ro(".config/13-epub_page_size/height"); if(readFile(".config/13-epub_page_size/height").isEmpty()) {
if(checkconfig_str_val != "") { QString pageHeight = QString::number(defaultEpubPageHeight);
; writeFile(".config/13-epub_page_size/height", pageHeight);
writeFile(".config/13-epub_page_size/set", "true");
} }
else { mupdf::epub::height = readFile(".config/13-epub_page_size/height").toInt();
std::string pageHeight = std::to_string(defaultEpubPageHeight);
string_writeconfig(".config/13-epub_page_size/height", pageHeight);
string_writeconfig(".config/13-epub_page_size/set", "true");
string_checkconfig_ro(".config/13-epub_page_size/height");
}
mupdf::epub::height = checkconfig_str_val.toInt();
} }
else if(fileType == 1) { else if(fileType == 1) {
defineDefaultPageSize(1); defineDefaultPageSize(1);
@ -1765,16 +1744,16 @@ void reader::on_nightModeBtn_clicked()
if(isNightModeActive == true) { if(isNightModeActive == true) {
// Disabling night/dark mode // Disabling night/dark mode
log("Setting night mode to OFF", className); log("Setting night mode to OFF", className);
string_writeconfig("/tmp/invertScreen", "n"); writeFile("/tmp/invertScreen", "n");
string_writeconfig(".config/10-dark_mode/config", "false"); writeFile(".config/10-dark_mode/config", "false");
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png")); ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
isNightModeActive = false; isNightModeActive = false;
} }
else { else {
// Enabling night/dark mode // Enabling night/dark mode
log("Setting night mode to ON", className); log("Setting night mode to ON", className);
string_writeconfig("/tmp/invertScreen", "y"); writeFile("/tmp/invertScreen", "y");
string_writeconfig(".config/10-dark_mode/config", "true"); writeFile(".config/10-dark_mode/config", "true");
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png")); ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png"));
isNightModeActive = true; isNightModeActive = true;
} }
@ -1844,9 +1823,9 @@ void reader::getTotalEpubPagesNumber() {
epubProc->waitForFinished(); epubProc->waitForFinished();
epubProc->deleteLater(); epubProc->deleteLater();
string_checkconfig_ro("/run/epub_total_pages_number"); QString totalPages = readFile("/run/epub_total_pages_number");
totalPagesInt = checkconfig_str_val.toInt(); totalPagesInt = totalPages.toInt();
log("ePUB total pages number: " + checkconfig_str_val, className); log("ePUB total pages number: " + totalPages, className);
QFile::remove("/run/epub_total_pages_number"); QFile::remove("/run/epub_total_pages_number");
} }
@ -1996,11 +1975,11 @@ bool reader::pdf_file_match(QString file) {
if(fileExt == "pdf" or fileExt == "PDF") { if(fileExt == "pdf" or fileExt == "PDF") {
log("Book file format: PDF", className); log("Book file format: PDF", className);
string_writeconfig("/inkbox/bookIsPdf", "true"); writeFile("/inkbox/bookIsPdf", "true");
return true; return true;
} }
else { else {
string_writeconfig("/inkbox/bookIsPdf", "false"); writeFile("/inkbox/bookIsPdf", "false");
return false; return false;
} }
} }
@ -2008,16 +1987,16 @@ bool reader::pdf_file_match(QString file) {
bool reader::image_file_match(QString file) { bool reader::image_file_match(QString file) {
if(file.right(3) == "png" or file.right(3) == "PNG" or file.right(3) == "jpg" or file.right(3) == "JPG" or file.right(3) == "bmp" or file.right(3) == "BMP" or file.right(3) == "tif" or file.right(3) == "TIF") { if(file.right(3) == "png" or file.right(3) == "PNG" or file.right(3) == "jpg" or file.right(3) == "JPG" or file.right(3) == "bmp" or file.right(3) == "BMP" or file.right(3) == "tif" or file.right(3) == "TIF") {
log("File format: image", className); log("File format: image", className);
string_writeconfig("/inkbox/bookIsImage", "true"); writeFile("/inkbox/bookIsImage", "true");
return true; return true;
} }
else if(file.right(4) == "jpeg" or file.right(4) == "JPEG" or file.right(4) == "tiff" or file.right(4) == "TIFF") { else if(file.right(4) == "jpeg" or file.right(4) == "JPEG" or file.right(4) == "tiff" or file.right(4) == "TIFF") {
log("File format: image", className); log("File format: image", className);
string_writeconfig("/inkbox/bookIsImage", "true"); writeFile("/inkbox/bookIsImage", "true");
return true; return true;
} }
else { else {
string_writeconfig("/inkbox/bookIsImage", "false"); writeFile("/inkbox/bookIsImage", "false");
return false; return false;
} }
} }
@ -2032,9 +2011,9 @@ void reader::getTotalPdfPagesNumber() {
epubProc->waitForFinished(); epubProc->waitForFinished();
epubProc->deleteLater(); epubProc->deleteLater();
string_checkconfig_ro("/run/pdf_total_pages_number"); QString totalPages = readFile("/run/pdf_total_pages_number");
totalPagesInt = checkconfig_str_val.toInt(); totalPagesInt = totalPages.toInt();
log("Total PDF pages number: " + checkconfig_str_val, className); log("Total PDF pages number: " + totalPages, className);
QFile::remove("/run/pdf_total_pages_number"); QFile::remove("/run/pdf_total_pages_number");
} }
@ -2131,8 +2110,8 @@ void reader::closeIndefiniteToast() {
void reader::getPdfOrientation(QString file) { void reader::getPdfOrientation(QString file) {
log("Getting viewport orientation for PDF file '" + file + "'", className); log("Getting viewport orientation for PDF file '" + file + "'", className);
string_writeconfig("/inkbox/pdf_orientation_file_request", file.toStdString()); writeFile("/inkbox/pdf_orientation_file_request", file);
string_writeconfig("/opt/ibxd", "get_pdf_orientation\n"); writeFile("/opt/ibxd", "get_pdf_orientation\n");
while(true) { while(true) {
if(QFile::exists("/inkbox/pdf_orientation_result")) { if(QFile::exists("/inkbox/pdf_orientation_result")) {
QString result = readFile("/inkbox/pdf_orientation_result").trimmed(); QString result = readFile("/inkbox/pdf_orientation_result").trimmed();
@ -2273,7 +2252,7 @@ void reader::on_brightnessBtn_clicked()
void reader::setCinematicBrightnessWarmthSlot() { void reader::setCinematicBrightnessWarmthSlot() {
if(global::reader::globalReadingSettings == false) { if(global::reader::globalReadingSettings == false) {
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") { if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
int brightness_value = brightness_checkconfig(".config/03-brightness/config"); int brightness_value = brightnessCheckconfig(".config/03-brightness/config");
log("Local Reading Settings: Setting brightness to " + QString::number(brightness_value), className); log("Local Reading Settings: Setting brightness to " + QString::number(brightness_value), className);
cinematicBrightness(brightness_value, 2); cinematicBrightness(brightness_value, 2);
} }

View file

@ -40,8 +40,8 @@ koboxSettings::koboxSettings(QWidget *parent) :
// DPI setting // DPI setting
QString dpiSetting; QString dpiSetting;
string_checkconfig(".config/00-kobox/dpiSetting"); QString dpiSettingStr = readFile(".config/00-kobox/dpiSetting");
if(checkconfig_str_val == "") { if(dpiSettingStr.isEmpty()) {
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") { if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
dpiSetting = "125"; dpiSetting = "125";
} }
@ -57,12 +57,11 @@ koboxSettings::koboxSettings(QWidget *parent) :
else { else {
dpiSetting = "125"; dpiSetting = "125";
} }
std::string dpiSetting_str = dpiSetting.toStdString(); writeFile(".config/00-kobox/dpiSetting", dpiSetting);
string_writeconfig(".config/00-kobox/dpiSetting", dpiSetting_str);
} }
string_checkconfig(".config/00-kobox/dpiSetting"); readFile(".config/00-kobox/dpiSetting");
int dpi_setting = checkconfig_str_val.toInt(); int dpi_setting = dpiSettingStr.toInt();
ui->spinBox->setValue(dpi_setting); ui->spinBox->setValue(dpi_setting);
} }
@ -112,8 +111,7 @@ void koboxSettings::openResetKoboxDialog() {
void koboxSettings::on_spinBox_valueChanged(int arg1) void koboxSettings::on_spinBox_valueChanged(int arg1)
{ {
QString number = QString::number(arg1); QString number = QString::number(arg1);
string number_str = number.toStdString(); writeFile(".config/00-kobox/dpiSetting", number);
string_writeconfig(".config/00-kobox/dpiSetting", number_str);
log("X11 DPI set to " + number, className); log("X11 DPI set to " + number, className);
} }

View file

@ -117,8 +117,8 @@ settings::settings(QWidget *parent) :
} }
// Words number // Words number
string_checkconfig(".config/07-words_number/config"); QString wordsNumberConfigStr = readFile(".config/07-words_number/config");
if(checkconfig_str_val == "") { if(wordsNumberConfigStr.isEmpty()) {
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
wordsNumberSaved = 120; wordsNumberSaved = 120;
} }
@ -130,17 +130,17 @@ settings::settings(QWidget *parent) :
} }
} }
else { else {
QString words_number = checkconfig_str_val; QString words_number = wordsNumberConfigStr;
wordsNumberSaved = checkconfig_str_val.toInt(); wordsNumberSaved = wordsNumberConfigStr.toInt();
} }
ui->wordsNumberValueLabel->setText(QString::number(wordsNumberSaved)); ui->wordsNumberValueLabel->setText(QString::number(wordsNumberSaved));
// ePUB page size // ePUB page size
if(checkconfig(".config/13-epub_page_size/set") == true) { if(checkconfig(".config/13-epub_page_size/set") == true) {
string_checkconfig_ro(".config/13-epub_page_size/width"); QString epubPageWidthSettingStr = readFile(".config/13-epub_page_size/width");
if(checkconfig_str_val != "") { if(!epubPageWidthSettingStr.isEmpty()) {
QString pageWidth = checkconfig_str_val; QString pageWidth = epubPageWidthSettingStr;
ui->pageSizeWidthLabel->setText(pageWidth); ui->pageSizeWidthLabel->setText(pageWidth);
pageSizeWidthSaved = pageWidth.toInt(); pageSizeWidthSaved = pageWidth.toInt();
} }
@ -149,9 +149,9 @@ settings::settings(QWidget *parent) :
ui->pageSizeWidthLabel->setText(QString::number(defaultEpubPageWidth)); ui->pageSizeWidthLabel->setText(QString::number(defaultEpubPageWidth));
pageSizeWidthSaved = defaultEpubPageWidth; pageSizeWidthSaved = defaultEpubPageWidth;
} }
string_checkconfig_ro(".config/13-epub_page_size/height"); QString epubPageHeightSettingStr = readFile(".config/13-epub_page_size/height");
if(checkconfig_str_val != "") { if(!epubPageHeightSettingStr.isEmpty()) {
QString pageHeight = checkconfig_str_val; QString pageHeight = epubPageHeightSettingStr;
ui->pageSizeHeightLabel->setText(pageHeight); ui->pageSizeHeightLabel->setText(pageHeight);
pageSizeHeightSaved = pageHeight.toInt(); pageSizeHeightSaved = pageHeight.toInt();
} }
@ -179,30 +179,30 @@ settings::settings(QWidget *parent) :
} }
// Scaling // Scaling
string_checkconfig(".config/09-dpi/config"); QString dpiSettingStr = readFile(".config/09-dpi/config");
if(checkconfig_str_val == "") { if(dpiSettingStr.isEmpty()) {
// Writing default value depending on the device // Writing default value depending on the device
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
string_writeconfig(".config/09-dpi/config", "187"); writeFile(".config/09-dpi/config", "187");
} }
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") { else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
string_writeconfig(".config/09-dpi/config", "160"); writeFile(".config/09-dpi/config", "160");
} }
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") { else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
string_writeconfig(".config/09-dpi/config", "195"); writeFile(".config/09-dpi/config", "195");
} }
else if(global::deviceID == "n437\n") { else if(global::deviceID == "n437\n") {
string_writeconfig(".config/09-dpi/config", "275"); writeFile(".config/09-dpi/config", "275");
} }
else if(global::deviceID == "n873\n") { else if(global::deviceID == "n873\n") {
string_writeconfig(".config/09-dpi/config", "285"); writeFile(".config/09-dpi/config", "285");
} }
else { else {
string_writeconfig(".config/09-dpi/config", "187"); writeFile(".config/09-dpi/config", "187");
} }
} }
else { else {
int dpi_number = checkconfig_str_val.toInt(); int dpi_number = dpiSettingStr.toInt();
// Checking if it's a Mini, Touch or a Glo // Checking if it's a Mini, Touch or a Glo
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
if(dpi_number == 187) { if(dpi_number == 187) {
@ -284,14 +284,14 @@ settings::settings(QWidget *parent) :
} }
// Refresh // Refresh
string_checkconfig_ro(".config/04-book/refresh"); QString refreshSettingStr = readFile(".config/04-book/refresh");
if(checkconfig_str_val == "") { if(refreshSettingStr.isEmpty()) {
// Set default option, 3 // Set default option, 3
string_writeconfig(".config/04-book/refresh", "3"); writeFile(".config/04-book/refresh", "3");
ui->comboBox->setCurrentText("3 pages"); ui->comboBox->setCurrentText("3 pages");
} }
else { else {
int refreshInt = checkconfig_str_val.toInt(); int refreshInt = refreshSettingStr.toInt();
if(refreshInt == -1) { if(refreshInt == -1) {
ui->comboBox->setCurrentText("Never refresh"); ui->comboBox->setCurrentText("Never refresh");
} }
@ -474,9 +474,8 @@ void settings::on_aboutBtn_clicked()
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
QString aboutmsg = "InkBox is an open-source, Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive."; QString aboutmsg = "InkBox is an open-source, Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive.";
aboutmsg.prepend("<font face='u001'>"); aboutmsg.prepend("<font face='u001'>");
string_checkconfig_ro("/external_root/opt/isa/version");
aboutmsg.append("<br><br>InkBox "); aboutmsg.append("<br><br>InkBox ");
aboutmsg.append(checkconfig_str_val); aboutmsg.append(readFile("/external_root/opt/isa/version"));
aboutmsg.append("</font>"); aboutmsg.append("</font>");
QMessageBox::information(this, tr("Information"), aboutmsg); QMessageBox::information(this, tr("Information"), aboutmsg);
} }
@ -647,13 +646,13 @@ void settings::on_darkModeCheckBox_toggled(bool checked)
QString settingString = "dark mode"; QString settingString = "dark mode";
if(checked == true) { if(checked == true) {
logEnabled(settingString, className); logEnabled(settingString, className);
string_writeconfig(".config/10-dark_mode/config", "true"); writeFile(".config/10-dark_mode/config", "true");
string_writeconfig("/tmp/invertScreen", "y"); writeFile("/tmp/invertScreen", "y");
} }
else { else {
logDisabled(settingString, className); logDisabled(settingString, className);
string_writeconfig(".config/10-dark_mode/config", "false"); writeFile(".config/10-dark_mode/config", "false");
string_writeconfig("/tmp/invertScreen", "n"); writeFile("/tmp/invertScreen", "n");
} }
} }
@ -662,62 +661,62 @@ void settings::on_uiScalingSlider_valueChanged(int value)
log("Setting DPI level to " + QString::number(value), className); log("Setting DPI level to " + QString::number(value), className);
if(value == 0) { if(value == 0) {
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
string_writeconfig(".config/09-dpi/config", "187"); writeFile(".config/09-dpi/config", "187");
} }
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") { if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
string_writeconfig(".config/09-dpi/config", "160"); writeFile(".config/09-dpi/config", "160");
} }
if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") { if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") {
string_writeconfig(".config/09-dpi/config", "195"); writeFile(".config/09-dpi/config", "195");
} }
if(global::deviceID == "n306\n") { if(global::deviceID == "n306\n") {
string_writeconfig(".config/09-dpi/config", "212"); writeFile(".config/09-dpi/config", "212");
} }
if(global::deviceID == "n437\n") { if(global::deviceID == "n437\n") {
string_writeconfig(".config/09-dpi/config", "275"); writeFile(".config/09-dpi/config", "275");
} }
if(global::deviceID == "n873\n") { if(global::deviceID == "n873\n") {
string_writeconfig(".config/09-dpi/config", "285"); writeFile(".config/09-dpi/config", "285");
} }
} }
if(value == 1) { if(value == 1) {
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
string_writeconfig(".config/09-dpi/config", "214"); writeFile(".config/09-dpi/config", "214");
} }
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") { if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
string_writeconfig(".config/09-dpi/config", "187"); writeFile(".config/09-dpi/config", "187");
} }
if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") { if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") {
string_writeconfig(".config/09-dpi/config", "210"); writeFile(".config/09-dpi/config", "210");
} }
if(global::deviceID == "n306\n") { if(global::deviceID == "n306\n") {
string_writeconfig(".config/09-dpi/config", "227"); writeFile(".config/09-dpi/config", "227");
} }
if(global::deviceID == "n437\n") { if(global::deviceID == "n437\n") {
string_writeconfig(".config/09-dpi/config", "290"); writeFile(".config/09-dpi/config", "290");
} }
if(global::deviceID == "n873\n") { if(global::deviceID == "n873\n") {
string_writeconfig(".config/09-dpi/config", "300"); writeFile(".config/09-dpi/config", "300");
} }
} }
if(value == 2) { if(value == 2) {
if(global::deviceID == "n705\n") { if(global::deviceID == "n705\n") {
string_writeconfig(".config/09-dpi/config", "227"); writeFile(".config/09-dpi/config", "227");
} }
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") { if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
string_writeconfig(".config/09-dpi/config", "200"); writeFile(".config/09-dpi/config", "200");
} }
if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") { if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") {
string_writeconfig(".config/09-dpi/config", "225"); writeFile(".config/09-dpi/config", "225");
} }
if(global::deviceID == "n306\n") { if(global::deviceID == "n306\n") {
string_writeconfig(".config/09-dpi/config", "242"); writeFile(".config/09-dpi/config", "242");
} }
if(global::deviceID == "n437\n") { if(global::deviceID == "n437\n") {
string_writeconfig(".config/09-dpi/config", "305"); writeFile(".config/09-dpi/config", "305");
} }
if(global::deviceID == "n873\n") { if(global::deviceID == "n873\n") {
string_writeconfig(".config/09-dpi/config", "315"); writeFile(".config/09-dpi/config", "315");
} }
} }
@ -756,28 +755,28 @@ void settings::on_comboBox_currentIndexChanged(const QString &arg1)
{ {
log("Setting page refresh setting to " + arg1, className); log("Setting page refresh setting to " + arg1, className);
if(arg1 == "Every page") { if(arg1 == "Every page") {
string_writeconfig(".config/04-book/refresh", "0"); writeFile(".config/04-book/refresh", "0");
} }
if(arg1 == "1 page") { if(arg1 == "1 page") {
string_writeconfig(".config/04-book/refresh", "1"); writeFile(".config/04-book/refresh", "1");
} }
if(arg1 == "2 pages") { if(arg1 == "2 pages") {
string_writeconfig(".config/04-book/refresh", "2"); writeFile(".config/04-book/refresh", "2");
} }
if(arg1 == "3 pages") { if(arg1 == "3 pages") {
string_writeconfig(".config/04-book/refresh", "3"); writeFile(".config/04-book/refresh", "3");
} }
if(arg1 == "4 pages") { if(arg1 == "4 pages") {
string_writeconfig(".config/04-book/refresh", "4"); writeFile(".config/04-book/refresh", "4");
} }
if(arg1 == "5 pages") { if(arg1 == "5 pages") {
string_writeconfig(".config/04-book/refresh", "5"); writeFile(".config/04-book/refresh", "5");
} }
if(arg1 == "6 pages") { if(arg1 == "6 pages") {
string_writeconfig(".config/04-book/refresh", "6"); writeFile(".config/04-book/refresh", "6");
} }
if(arg1 == "Never refresh") { if(arg1 == "Never refresh") {
string_writeconfig(".config/04-book/refresh", "-1"); writeFile(".config/04-book/refresh", "-1");
} }
} }
@ -785,7 +784,7 @@ void settings::on_resetBtn_clicked()
{ {
log("'Reset' button clicked", className); log("'Reset' button clicked", className);
// We write to a temporary file to show a "Reset" prompt // We write to a temporary file to show a "Reset" prompt
string_writeconfig("/inkbox/resetDialog", "true"); writeFile("/inkbox/resetDialog", "true");
// We setup the dialog // We setup the dialog
log("Showing reset dialog", className); log("Showing reset dialog", className);
@ -798,7 +797,7 @@ void settings::on_setPasscodeBtn_clicked()
log("'Set passcode' button clicked", className); log("'Set passcode' button clicked", className);
log("Launching lockscreen binary", className); log("Launching lockscreen binary", className);
saveDeferredSettings(); saveDeferredSettings();
string_writeconfig("/tmp/setPasscode", "true"); writeFile("/tmp/setPasscode", "true");
QProcess process; QProcess process;
process.startDetached("lockscreen", QStringList()); process.startDetached("lockscreen", QStringList());
qApp->quit(); qApp->quit();
@ -842,11 +841,11 @@ void settings::on_readerScrollBarCheckBox_toggled(bool checked)
QString settingString = "scrollbar display if necessary"; QString settingString = "scrollbar display if necessary";
if(checked == true) { if(checked == true) {
logEnabled(settingString, className); logEnabled(settingString, className);
string_writeconfig(".config/14-reader_scrollbar/config", "true"); writeFile(".config/14-reader_scrollbar/config", "true");
} }
else { else {
logDisabled(settingString, className); logDisabled(settingString, className);
string_writeconfig(".config/14-reader_scrollbar/config", "false"); writeFile(".config/14-reader_scrollbar/config", "false");
} }
} }
@ -884,7 +883,7 @@ void settings::openUpdateDialog() {
log("Showing update dialog", className); log("Showing update dialog", className);
global::mainwindow::updateDialog = true; global::mainwindow::updateDialog = true;
// Write to a temporary file to show an "Update" prompt // Write to a temporary file to show an "Update" prompt
string_writeconfig("/inkbox/updateDialog", "true"); writeFile("/inkbox/updateDialog", "true");
// Show the dialog // Show the dialog
generalDialogWindow = new generalDialog(this); generalDialogWindow = new generalDialog(this);
@ -935,7 +934,7 @@ void settings::usbms_launch()
void settings::quit_restart() { void settings::quit_restart() {
// If existing, cleaning bookconfig_mount mountpoint // If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n"); writeFile("/opt/ibxd", "bookconfig_unmount\n");
// Restarting InkBox // Restarting InkBox
QProcess process; QProcess process;
@ -950,8 +949,8 @@ void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked)
if(enableEncryptedStorageUserChange == true) { if(enableEncryptedStorageUserChange == true) {
logEnabled(settingString, className); logEnabled(settingString, className);
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "false"); writeFile(".config/18-encrypted_storage/initial_setup_done", "false");
string_writeconfig(".config/18-encrypted_storage/status", "true"); writeFile(".config/18-encrypted_storage/status", "true");
if(QFile::exists(".config/18-encrypted_storage/storage_list")) { if(QFile::exists(".config/18-encrypted_storage/storage_list")) {
QFile::remove(".config/18-encrypted_storage/storage_list"); QFile::remove(".config/18-encrypted_storage/storage_list");
} }
@ -977,11 +976,11 @@ void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked)
void settings::disableStorageEncryption() { void settings::disableStorageEncryption() {
log("Disabling encrypted storage", className); log("Disabling encrypted storage", className);
setDefaultWorkDir(); setDefaultWorkDir();
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true"); writeFile("/external_root/run/encfs_stop_cleanup", "true");
string_writeconfig("/opt/ibxd", "encfs_stop\n"); writeFile("/opt/ibxd", "encfs_stop\n");
QThread::msleep(5000); QThread::msleep(5000);
string_writeconfig(".config/18-encrypted_storage/status", "false"); writeFile(".config/18-encrypted_storage/status", "false");
QFile::remove(".config/18-encrypted_storage/initial_setup_done"); QFile::remove(".config/18-encrypted_storage/initial_setup_done");
QFile::remove(".config/18-encrypted_storage/storage_list"); QFile::remove(".config/18-encrypted_storage/storage_list");
QFile::remove("/mnt/onboard/onboard/data.encfs"); QFile::remove("/mnt/onboard/onboard/data.encfs");
@ -1013,7 +1012,7 @@ void settings::on_repackBtn_clicked()
} }
else { else {
log("Showing encrypted storage repack dialog", className); log("Showing encrypted storage repack dialog", className);
string_writeconfig("/external_root/run/encfs_repack", "true"); writeFile("/external_root/run/encfs_repack", "true");
quit_restart(); quit_restart();
} }
} }
@ -1022,7 +1021,7 @@ void settings::on_generateSystemReportBtn_clicked()
{ {
log("'Generate system report' button clicked", className); log("'Generate system report' button clicked", className);
log("Generating system report", className); log("Generating system report", className);
string_writeconfig("/opt/ibxd", "generate_system_report\n"); writeFile("/opt/ibxd", "generate_system_report\n");
while(true) { while(true) {
if(QFile::exists("/inkbox/systemReportDone")) { if(QFile::exists("/inkbox/systemReportDone")) {
if(checkconfig("/inkbox/systemReportDone") == true) { if(checkconfig("/inkbox/systemReportDone") == true) {
@ -1049,8 +1048,8 @@ void settings::on_tzComboBox_currentTextChanged(const QString &arg1)
// Preventing unnecessary (e)MMC writes // Preventing unnecessary (e)MMC writes
if(readFile(".config/19-timezone/config-name") != arg1) { if(readFile(".config/19-timezone/config-name") != arg1) {
QProcess::execute("ln", QStringList() << "-sf" << "/usr/share/zoneinfo/" + arg1 << ".config/19-timezone/config"); QProcess::execute("ln", QStringList() << "-sf" << "/usr/share/zoneinfo/" + arg1 << ".config/19-timezone/config");
string_writeconfig(".config/19-timezone/config-name", arg1.toStdString()); writeFile(".config/19-timezone/config-name", arg1);
string_writeconfig("/opt/ibxd", "gui_remount_localtime\n"); writeFile("/opt/ibxd", "gui_remount_localtime\n");
QThread::msleep(500); QThread::msleep(500);
} }
} }
@ -1127,11 +1126,11 @@ void settings::on_usbmsDialogBox_clicked(bool checked)
QString settingString = "USB Mass Storage dialog display"; QString settingString = "USB Mass Storage dialog display";
if(checked == true) { if(checked == true) {
logEnabled(settingString, className); logEnabled(settingString, className);
string_writeconfig(".config/22-usb/show-dialog", "true"); writeFile(".config/22-usb/show-dialog", "true");
} }
else { else {
logDisabled(settingString, className); logDisabled(settingString, className);
string_writeconfig(".config/22-usb/show-dialog", "false"); writeFile(".config/22-usb/show-dialog", "false");
} }
} }
@ -1140,11 +1139,11 @@ void settings::on_autoCheckUpdatesBox_clicked(bool checked)
QString settingString = "automatic updates checking"; QString settingString = "automatic updates checking";
if(checked == true) { if(checked == true) {
logEnabled(settingString, className); logEnabled(settingString, className);
string_writeconfig(".config/23-updates/check-updates", "true"); writeFile(".config/23-updates/check-updates", "true");
} }
else { else {
logDisabled(settingString, className); logDisabled(settingString, className);
string_writeconfig(".config/23-updates/check-updates", "false"); writeFile(".config/23-updates/check-updates", "false");
} }
} }

View file

@ -67,25 +67,25 @@ usbmsSplash::usbmsSplash(QWidget *parent) :
void usbmsSplash::usbmsLaunch() void usbmsSplash::usbmsLaunch()
{ {
log("Entering USBMS session", className); log("Entering USBMS session", className);
string_writeconfig("/tmp/in_usbms", "true"); writeFile("/tmp/in_usbms", "true");
QTimer::singleShot(1500, this, SLOT(brightnessDown())); QTimer::singleShot(1500, this, SLOT(brightnessDown()));
if(global::usbms::koboxExportExtensions == true) { if(global::usbms::koboxExportExtensions == true) {
string_writeconfig("/opt/ibxd", "kobox_extensions_storage_unmount\n"); writeFile("/opt/ibxd", "kobox_extensions_storage_unmount\n");
} }
if(checkconfig("/external_root/run/encfs_mounted") == true) { if(checkconfig("/external_root/run/encfs_mounted") == true) {
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true"); writeFile("/external_root/run/encfs_stop_cleanup", "true");
string_writeconfig("/opt/ibxd", "encfs_stop\n"); writeFile("/opt/ibxd", "encfs_stop\n");
QThread::msleep(1500); QThread::msleep(1500);
} }
string_writeconfig("/opt/ibxd", "onboard_unmount\n"); writeFile("/opt/ibxd", "onboard_unmount\n");
QThread::msleep(1000); QThread::msleep(1000);
string_writeconfig("/opt/ibxd", "usbnet_stop\n"); writeFile("/opt/ibxd", "usbnet_stop\n");
QThread::msleep(1000); QThread::msleep(1000);
string_writeconfig("/opt/ibxd", "gui_apps_stop\n"); writeFile("/opt/ibxd", "gui_apps_stop\n");
QThread::msleep(1000); QThread::msleep(1000);
if(global::deviceID == "n306\n" or global::deviceID == "n873\n") { if(global::deviceID == "n306\n" or global::deviceID == "n873\n") {
@ -181,7 +181,7 @@ void usbmsSplash::brightnessDown() {
void usbmsSplash::quit_restart() { void usbmsSplash::quit_restart() {
// If existing, cleaning bookconfig_mount mountpoint // If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n"); writeFile("/opt/ibxd", "bookconfig_unmount\n");
// Restarting InkBox // Restarting InkBox
QProcess process; QProcess process;
@ -192,17 +192,17 @@ void usbmsSplash::quit_restart() {
void usbmsSplash::restartServices() { void usbmsSplash::restartServices() {
// Restarting USBNet // Restarting USBNet
// NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet) // NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet)
string_writeconfig("/opt/ibxd", "usbnet_start\n"); writeFile("/opt/ibxd", "usbnet_start\n");
QThread::msleep(1000); QThread::msleep(1000);
// Mounting onboard storage // Mounting onboard storage
string_writeconfig("/opt/ibxd", "onboard_mount\n"); writeFile("/opt/ibxd", "onboard_mount\n");
QThread::msleep(1000); QThread::msleep(1000);
// Checking for updates // Checking for updates
string_writeconfig("/opt/ibxd", "update_inkbox_restart\n"); writeFile("/opt/ibxd", "update_inkbox_restart\n");
QThread::msleep(2500); QThread::msleep(2500);
QFile::remove("/tmp/in_usbms"); QFile::remove("/tmp/in_usbms");
// GUI apps: update main JSON file // GUI apps: update main JSON file
string_writeconfig("/opt/ibxd", "gui_apps_start\n"); writeFile("/opt/ibxd", "gui_apps_start\n");
while(true) { while(true) {
if(QFile::exists("/tmp/gui_apps_started")) { if(QFile::exists("/tmp/gui_apps_started")) {
if(checkconfig("/tmp/gui_apps_started") == true) { if(checkconfig("/tmp/gui_apps_started") == true) {

View file

@ -73,18 +73,18 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
int value; int value;
int warmthValue; int warmthValue;
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) { if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
value = get_brightness(); value = getBrightness();
if(global::isN873 == true) { if(global::isN873 == true) {
warmthValue = get_warmth(); warmthValue = getWarmth();
ui->warmthSlider->setValue(warmthValue); ui->warmthSlider->setValue(warmthValue);
} }
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
setDefaultWorkDir(); setDefaultWorkDir();
value = brightness_checkconfig(".config/03-brightness/config"); value = brightnessCheckconfig(".config/03-brightness/config");
} }
else { else {
value = get_brightness(); value = getBrightness();
} }
// Setting the slider to the appropriate position // Setting the slider to the appropriate position
@ -96,24 +96,24 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
ui->valueLabel->setText(valueStr); ui->valueLabel->setText(valueStr);
// Warmth value label // Warmth value label
if(global::isN873 == true) { if(global::isN873 == true) {
warmthValue = get_warmth(); warmthValue = getWarmth();
QString warmthValueStr = QString::number(warmthValue); QString warmthValueStr = QString::number(warmthValue);
ui->warmthValueLabel->setText(warmthValueStr); ui->warmthValueLabel->setText(warmthValueStr);
} }
// Saving current brightness value in case we want to go backwards // Saving current brightness value in case we want to go backwards
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) { if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
oldValue = get_brightness(); oldValue = getBrightness();
if(global::isN873 == true) { if(global::isN873 == true) {
oldWarmthValue = get_warmth(); oldWarmthValue = getWarmth();
} }
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
setDefaultWorkDir(); setDefaultWorkDir();
oldValue = brightness_checkconfig(".config/03-brightness/config"); oldValue = brightnessCheckconfig(".config/03-brightness/config");
} }
else { else {
oldValue = get_brightness(); oldValue = getBrightness();
} }
} }
@ -125,15 +125,15 @@ brightnessDialog::~brightnessDialog()
void brightnessDialog::on_quitBtn_clicked() void brightnessDialog::on_quitBtn_clicked()
{ {
// Reverting back to the old value // Reverting back to the old value
brightnessDialog::pre_set_brightness(oldValue); brightnessDialog::preSetBrightness(oldValue);
if(global::isN873 == true) { if(global::isN873 == true) {
set_warmth(oldWarmthValue); setWarmth(oldWarmthValue);
} }
// Just in case ;) // Just in case ;)
brightness_writeconfig(oldValue); brightnessWriteconfig(oldValue);
if(global::isN873 == true) { if(global::isN873 == true) {
warmth_writeconfig(oldWarmthValue); warmthWriteconfig(oldWarmthValue);
} }
// Leaving // Leaving
@ -142,7 +142,7 @@ void brightnessDialog::on_quitBtn_clicked()
void brightnessDialog::on_horizontalSlider_valueChanged(int value) void brightnessDialog::on_horizontalSlider_valueChanged(int value)
{ {
brightnessDialog::pre_set_brightness(value); brightnessDialog::preSetBrightness(value);
QString valueStr = QString::number(value); QString valueStr = QString::number(value);
valueStr = valueStr.append("%"); valueStr = valueStr.append("%");
ui->valueLabel->setText(valueStr); ui->valueLabel->setText(valueStr);
@ -170,32 +170,32 @@ void brightnessDialog::on_okBtn_clicked()
// Write brightness config // Write brightness config
log("Display brightness set to " + QString::number(brightnessValue), className); log("Display brightness set to " + QString::number(brightnessValue), className);
brightness_writeconfig(brightnessValue); brightnessWriteconfig(brightnessValue);
if(global::isN873 == true) { if(global::isN873 == true) {
warmthValue = ui->warmthSlider->value(); warmthValue = ui->warmthSlider->value();
log("Display warmth set to " + QString::number(warmthValue), className); log("Display warmth set to " + QString::number(warmthValue), className);
warmth_writeconfig(warmthValue); warmthWriteconfig(warmthValue);
} }
// Leaving // Leaving
brightnessDialog::close(); brightnessDialog::close();
} }
void brightnessDialog::pre_set_brightness(int brightnessValue) { void brightnessDialog::preSetBrightness(int brightnessValue) {
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) { if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
set_brightness(brightnessValue); setBrightness(brightnessValue);
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
set_brightness_ntxio(brightnessValue); setBrightness_ntxio(brightnessValue);
} }
else { else {
set_brightness(brightnessValue); setBrightness(brightnessValue);
} }
} }
void brightnessDialog::on_warmthSlider_valueChanged(int value) void brightnessDialog::on_warmthSlider_valueChanged(int value)
{ {
set_warmth(value); setWarmth(value);
QString valueStr = QString::number(value); QString valueStr = QString::number(value);
ui->warmthValueLabel->setText(valueStr); ui->warmthValueLabel->setText(valueStr);
} }

View file

@ -15,10 +15,9 @@ class brightnessDialog : public QDialog
public: public:
QString className = this->metaObject()->className(); QString className = this->metaObject()->className();
QString checkconfig_str_val;
int oldValue; int oldValue;
int oldWarmthValue; int oldWarmthValue;
void pre_set_brightness(int brightnessValue); void preSetBrightness(int brightnessValue);
explicit brightnessDialog(QWidget *parent = nullptr); explicit brightnessDialog(QWidget *parent = nullptr);
~brightnessDialog(); ~brightnessDialog();

View file

@ -57,14 +57,14 @@ generalDialog::generalDialog(QWidget *parent) :
} }
if(QFile::exists("/inkbox/searchComboBoxFunction") == true) { if(QFile::exists("/inkbox/searchComboBoxFunction") == true) {
string_checkconfig_ro("/inkbox/searchComboBoxFunction"); QString searchComboBoxFunction = readFile("/inkbox/searchComboBoxFunction");
if(checkconfig_str_val == "Dictionary") { if(searchComboBoxFunction == "Dictionary") {
ui->searchComboBox->setCurrentIndex(0); ui->searchComboBox->setCurrentIndex(0);
} }
else if(checkconfig_str_val == "Local storage") { else if(searchComboBoxFunction == "Local storage") {
ui->searchComboBox->setCurrentIndex(1); ui->searchComboBox->setCurrentIndex(1);
} }
else if(checkconfig_str_val == "Online library") { else if(searchComboBoxFunction == "Online library") {
ui->searchComboBox->setCurrentIndex(2); ui->searchComboBox->setCurrentIndex(2);
} }
else { else {
@ -85,7 +85,7 @@ generalDialog::generalDialog(QWidget *parent) :
} }
ui->headerLabel->setText("Warning"); ui->headerLabel->setText("Warning");
QTimer::singleShot(50, this, SLOT(adjust_size())); QTimer::singleShot(50, this, SLOT(adjust_size()));
string_writeconfig("/inkbox/resetDialog", "false"); writeFile("/inkbox/resetDialog", "false");
} }
else { else {
resetDialog = true; resetDialog = true;
@ -94,7 +94,7 @@ generalDialog::generalDialog(QWidget *parent) :
ui->bodyLabel->setText("Settings will be reset."); ui->bodyLabel->setText("Settings will be reset.");
ui->headerLabel->setText("Warning"); ui->headerLabel->setText("Warning");
QTimer::singleShot(50, this, SLOT(adjust_size())); QTimer::singleShot(50, this, SLOT(adjust_size()));
string_writeconfig("/inkbox/resetDialog", "false"); writeFile("/inkbox/resetDialog", "false");
} }
} }
else if(checkconfig("/inkbox/updateDialog") == true) { else if(checkconfig("/inkbox/updateDialog") == true) {
@ -104,7 +104,7 @@ generalDialog::generalDialog(QWidget *parent) :
ui->bodyLabel->setText("<font face='u001'>Do you want to update InkBox now</font><font face='Inter'>?</font>"); // Because I hate Univers/U001's question mark ... ui->bodyLabel->setText("<font face='u001'>Do you want to update InkBox now</font><font face='Inter'>?</font>"); // Because I hate Univers/U001's question mark ...
ui->headerLabel->setText("Update available"); ui->headerLabel->setText("Update available");
QTimer::singleShot(50, this, SLOT(adjust_size())); QTimer::singleShot(50, this, SLOT(adjust_size()));
string_writeconfig("/inkbox/updateDialog", "false"); writeFile("/inkbox/updateDialog", "false");
} }
else if(global::settings::settingsRebootDialog == true) { else if(global::settings::settingsRebootDialog == true) {
settingsRebootDialog = true; settingsRebootDialog = true;
@ -122,13 +122,13 @@ generalDialog::generalDialog(QWidget *parent) :
else if(global::mainwindow::lowBatteryDialog == true) { else if(global::mainwindow::lowBatteryDialog == true) {
lowBatteryDialog = true; lowBatteryDialog = true;
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
get_battery_level(); getBatteryLevel();
QString message = "The battery's level is low.\nPlease charge your eReader.\nCurrent level: "; QString message = "The battery's level is low.\nPlease charge your eReader.\nCurrent level: ";
message.append(batt_level); message.append(batt_level);
ui->bodyLabel->setText(message); ui->bodyLabel->setText(message);
ui->headerLabel->setText("Low battery"); ui->headerLabel->setText("Low battery");
QTimer::singleShot(50, this, SLOT(adjust_size())); QTimer::singleShot(50, this, SLOT(adjust_size()));
string_writeconfig("/inkbox/lowBatteryDialog", "false"); writeFile("/inkbox/lowBatteryDialog", "false");
} }
else if(global::usbms::usbmsDialog == true) { else if(global::usbms::usbmsDialog == true) {
usbmsDialog = true; usbmsDialog = true;
@ -238,7 +238,7 @@ void generalDialog::on_cancelBtn_clicked()
{ {
log("Cancel button clicked", className); log("Cancel button clicked", className);
if(updateDialog == true) { if(updateDialog == true) {
string_writeconfig("/tmp/cancelUpdateDialog", "true"); writeFile("/tmp/cancelUpdateDialog", "true");
generalDialog::close(); generalDialog::close();
} }
else if(usbmsDialog == true) { else if(usbmsDialog == true) {
@ -367,7 +367,7 @@ void generalDialog::on_okBtn_clicked()
if(global::keyboard::searchDialog == true) { if(global::keyboard::searchDialog == true) {
if(!global::keyboard::keyboardText.isEmpty()) { if(!global::keyboard::keyboardText.isEmpty()) {
if(ui->searchComboBox->currentText() == "Dictionary") { if(ui->searchComboBox->currentText() == "Dictionary") {
string_writeconfig("/inkbox/searchComboBoxFunction", "Dictionary"); writeFile("/inkbox/searchComboBoxFunction", "Dictionary");
for(int i = ui->mainStackedWidget->count(); i >= 0; i--) { for(int i = ui->mainStackedWidget->count(); i >= 0; i--) {
QWidget * widget = ui->mainStackedWidget->widget(i); QWidget * widget = ui->mainStackedWidget->widget(i);
ui->mainStackedWidget->removeWidget(widget); ui->mainStackedWidget->removeWidget(widget);
@ -382,7 +382,7 @@ void generalDialog::on_okBtn_clicked()
ui->mainStackedWidget->insertWidget(1, dictionaryWidgetWindow); ui->mainStackedWidget->insertWidget(1, dictionaryWidgetWindow);
} }
else if(ui->searchComboBox->currentText() == "Local storage") { else if(ui->searchComboBox->currentText() == "Local storage") {
string_writeconfig("/inkbox/searchComboBoxFunction", "Local storage"); writeFile("/inkbox/searchComboBoxFunction", "Local storage");
QString onboardPath; QString onboardPath;
QStringList storageSearchResults; QStringList storageSearchResults;
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
@ -432,7 +432,7 @@ void generalDialog::on_okBtn_clicked()
} }
else if(ui->searchComboBox->currentText() == "Online library") { else if(ui->searchComboBox->currentText() == "Online library") {
if(testPing() == 0 or global::deviceID == "emu\n") { if(testPing() == 0 or global::deviceID == "emu\n") {
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library"); writeFile("/inkbox/searchComboBoxFunction", "Online library");
log("Searching online library for '" + global::keyboard::keyboardText + "'", className); log("Searching online library for '" + global::keyboard::keyboardText + "'", className);
if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) { if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) {
@ -456,8 +456,8 @@ void generalDialog::on_okBtn_clicked()
if(noGutenbergSyncToDo == true or (gutenbergSyncDone == true && gutenbergSyncStatus == true)) { if(noGutenbergSyncToDo == true or (gutenbergSyncDone == true && gutenbergSyncStatus == true)) {
if(searchTimerDone == false) { if(searchTimerDone == false) {
searchTimerDone = true; searchTimerDone = true;
string_writeconfig("/inkbox/gutenberg_search_request", global::keyboard::keyboardText.toStdString()); writeFile("/inkbox/gutenberg_search_request", global::keyboard::keyboardText);
string_writeconfig("/opt/ibxd", "gutenberg_search\n"); writeFile("/opt/ibxd", "gutenberg_search\n");
global::toast::modalToast = true; global::toast::modalToast = true;
global::toast::indefiniteToast = true; global::toast::indefiniteToast = true;
emit showToast("Searching"); emit showToast("Searching");
@ -546,7 +546,7 @@ void generalDialog::on_okBtn_clicked()
if(global::encfs::repackDialog == true) { if(global::encfs::repackDialog == true) {
global::encfs::repackDialog = false; global::encfs::repackDialog = false;
log("Encrypted storage repack requested", className); log("Encrypted storage repack requested", className);
string_writeconfig("/external_root/run/encfs_repack", "true"); writeFile("/external_root/run/encfs_repack", "true");
quit_restart(); quit_restart();
} }
else if(global::userApps::appCompatibilityDialog == true) { else if(global::userApps::appCompatibilityDialog == true) {
@ -655,13 +655,10 @@ void generalDialog::refreshScreenNative() {
void generalDialog::startVNC(QString server, QString password, QString port) { void generalDialog::startVNC(QString server, QString password, QString port) {
log("Launching VNC viewer", className); log("Launching VNC viewer", className);
std::string server_str = server.toStdString(); writeFile("/external_root/tmp/app_vnc_server", server);
std::string password_str = password.toStdString(); writeFile("/external_root/tmp/app_vnc_password", password);
std::string port_str = port.toStdString(); writeFile("/external_root/tmp/app_vnc_port", port);
string_writeconfig("/external_root/tmp/app_vnc_server", server_str); writeFile("/opt/ibxd", "app_start_vnc\n");
string_writeconfig("/external_root/tmp/app_vnc_password", password_str);
string_writeconfig("/external_root/tmp/app_vnc_port", port_str);
string_writeconfig("/opt/ibxd", "app_start_vnc\n");
qApp->quit(); qApp->quit();
} }
@ -694,7 +691,7 @@ void generalDialog::closeIndefiniteToastNative() {
void generalDialog::quit_restart() { void generalDialog::quit_restart() {
log("Restarting InkBox", className); log("Restarting InkBox", className);
// If existing, cleaning bookconfig_mount mountpoint // If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n"); writeFile("/opt/ibxd", "bookconfig_unmount\n");
// Restarting InkBox // Restarting InkBox
QProcess process; QProcess process;
@ -708,7 +705,7 @@ void generalDialog::syncGutenbergCatalog() {
global::toast::indefiniteToast = true; global::toast::indefiniteToast = true;
emit showToast("Sync in progress"); emit showToast("Sync in progress");
string_writeconfig("/opt/ibxd", "gutenberg_sync\n"); writeFile("/opt/ibxd", "gutenberg_sync\n");
QTimer * syncCheckTimer = new QTimer(this); QTimer * syncCheckTimer = new QTimer(this);
syncCheckTimer->setInterval(500); syncCheckTimer->setInterval(500);
connect(syncCheckTimer, &QTimer::timeout, [&]() { connect(syncCheckTimer, &QTimer::timeout, [&]() {

View file

@ -88,8 +88,8 @@ void koboxAppsDialog::on_launchBtn_clicked()
} }
else { else {
// DPI setting // DPI setting
string_checkconfig(".config/00-kobox/dpiSetting"); QString initialDpiSetting = readFile(".config/00-kobox/dpiSetting");
if(checkconfig_str_val == "") { if(initialDpiSetting.isEmpty()) {
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") { if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
dpiSetting = "125"; dpiSetting = "125";
} }
@ -108,7 +108,7 @@ void koboxAppsDialog::on_launchBtn_clicked()
} }
else { else {
dpiSetting = checkconfig_str_val.toStdString(); dpiSetting = initialDpiSetting;
} }
// Fullscreen or windowed (i3) // Fullscreen or windowed (i3)
@ -118,11 +118,11 @@ void koboxAppsDialog::on_launchBtn_clicked()
if(itemText == "Netsurf") { if(itemText == "Netsurf") {
log("Launching KoBox app: NetSurf", className); log("Launching KoBox app: NetSurf", className);
// Bypass standard shell script launch shenanigans // Bypass standard shell script launch shenanigans
string_writeconfig("/external_root/tmp/X_program", "!netsurf"); writeFile("/external_root/tmp/X_program", "!netsurf");
} }
else if(itemText == "KTerm") { else if(itemText == "KTerm") {
log("Launching KoBox app: KTerm", className); 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"); writeFile("/external_root/tmp/X_program", "/usr/local/bin/kterm -l /usr/local/share/kterm/layouts/keyboard-kt.xml -k 1");
dpModeSetting = "fullscreen"; dpModeSetting = "fullscreen";
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") { if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
dpiSetting = "175"; dpiSetting = "175";
@ -142,17 +142,16 @@ void koboxAppsDialog::on_launchBtn_clicked()
} }
else if(itemText == "Geany") { else if(itemText == "Geany") {
log("Launching KoBox app: Geany", className); log("Launching KoBox app: Geany", className);
string_writeconfig("/external_root/tmp/X_program", "geany"); writeFile("/external_root/tmp/X_program", "geany");
} }
else { else {
log("Launching KoBox app: " + itemText, className); log("Launching KoBox app: " + itemText, className);
QString itemTextLower = itemText.toLower(); QString app = itemText.toLower();
std::string app = itemTextLower.toStdString(); writeFile("/external_root/tmp/X_program", app);
string_writeconfig("/external_root/tmp/X_program", app);
} }
string_writeconfig("/external_root/tmp/X_dpmode", dpModeSetting); writeFile("/external_root/tmp/X_dpmode", dpModeSetting);
string_writeconfig("/external_root/tmp/X_dpi", dpiSetting); writeFile("/external_root/tmp/X_dpi", dpiSetting);
/* Wheeee! */ /* Wheeee! */
global::kobox::showKoboxSplash = true; global::kobox::showKoboxSplash = true;
@ -167,11 +166,11 @@ void koboxAppsDialog::on_launchBtn_clicked()
// Stop EncFS/Encrypted storage // Stop EncFS/Encrypted storage
if(checkconfig("/external_root/run/encfs_mounted") == true) { if(checkconfig("/external_root/run/encfs_mounted") == true) {
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true"); writeFile("/external_root/run/encfs_stop_cleanup", "true");
string_writeconfig("/opt/ibxd", "encfs_stop\n"); writeFile("/opt/ibxd", "encfs_stop\n");
} }
// Write to FIFO to start X11 // Write to FIFO to start X11
string_writeconfig("/opt/ibxd", "x_start_gui\n"); writeFile("/opt/ibxd", "x_start_gui\n");
} }
} }

View file

@ -23,8 +23,8 @@ public:
QString apps; QString apps;
QString itemText; QString itemText;
std::string dpiSetting; QString dpiSetting;
std::string dpModeSetting; QString dpModeSetting;
QModelIndex index; QModelIndex index;
private slots: private slots:

View file

@ -9,6 +9,7 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
ui(new Ui::bookInfoDialog) ui(new Ui::bookInfoDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
using global::bookInfoDialog::localInfoDialog;
// Preventing outside interaction // Preventing outside interaction
this->setModal(true); this->setModal(true);
@ -58,8 +59,8 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
QDir gutenbergDir; QDir gutenbergDir;
gutenbergDir.mkpath("/inkbox/gutenberg"); gutenbergDir.mkpath("/inkbox/gutenberg");
string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString()); writeFile("/inkbox/gutenberg/bookid", QString::number(global::library::bookId));
string_writeconfig("/opt/ibxd", "gutenberg_get_cover\n"); writeFile("/opt/ibxd", "gutenberg_get_cover\n");
while(true) { while(true) {
if(QFile::exists("/inkbox/gutenberg/getCoverDone")) { if(QFile::exists("/inkbox/gutenberg/getCoverDone")) {
if(checkconfig("/inkbox/gutenberg/getCoverDone") == true) { if(checkconfig("/inkbox/gutenberg/getCoverDone") == true) {
@ -148,9 +149,9 @@ void bookInfoDialog::on_getBtn_clicked()
{ {
QDir gutenbergDir; QDir gutenbergDir;
gutenbergDir.mkpath("/inkbox/gutenberg"); gutenbergDir.mkpath("/inkbox/gutenberg");
string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString()); writeFile("/inkbox/gutenberg/bookid", QString::number(global::library::bookId));
string_writeconfig("/inkbox/gutenberg/booktitle", global::library::bookTitle.toStdString()); writeFile("/inkbox/gutenberg/booktitle", global::library::bookTitle);
string_writeconfig("/opt/ibxd", "gutenberg_get_book\n"); writeFile("/opt/ibxd", "gutenberg_get_book\n");
global::toast::modalToast = true; global::toast::modalToast = true;
global::toast::indefiniteToast = true; global::toast::indefiniteToast = true;

View file

@ -343,7 +343,7 @@ void connectiondialog::on_connectBtn_clicked()
ui->cancelBtn->setEnabled(false); ui->cancelBtn->setEnabled(false);
if(checkWifiState() == global::wifi::wifiState::configured) { if(checkWifiState() == global::wifi::wifiState::configured) {
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n"); writeFile("/opt/ibxd", "stop_wifi_operations\n");
} }
writeFile("/run/wifi_network_essid", connectedNetworkData.name); writeFile("/run/wifi_network_essid", connectedNetworkData.name);
writeFile("/run/wifi_network_passphrase", finalPassphrase); writeFile("/run/wifi_network_passphrase", finalPassphrase);
@ -354,11 +354,11 @@ void connectiondialog::finalConnectWait() {
if(checkIfWifiBusy() == true) { if(checkIfWifiBusy() == true) {
// To be sure // To be sure
if(waitTry == 10) { if(waitTry == 10) {
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n"); writeFile("/opt/ibxd", "stop_wifi_operations\n");
} }
// Wait for everything to shut down; 10 seconds timeout // Wait for everything to shut down; 10 seconds timeout
if(waitTry == 20) { if(waitTry == 20) {
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n"); writeFile("/opt/ibxd", "stop_wifi_operations\n");
emit showToastSignal("Failed to stop other Wi-Fi processes"); emit showToastSignal("Failed to stop other Wi-Fi processes");
ui->cancelBtn->setEnabled(true); ui->cancelBtn->setEnabled(true);
} }
@ -368,12 +368,12 @@ void connectiondialog::finalConnectWait() {
} }
} }
else { else {
string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n"); writeFile("/opt/ibxd", "connect_to_wifi_network\n");
// This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script. // This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script.
log("Writing to configuration directory with connection information data", className); log("Writing to configuration directory with connection information data", className);
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString()); writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name);
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting.toStdString()); writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting);
this->deleteLater(); this->deleteLater();
this->close(); this->close();

View file

@ -314,7 +314,7 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
log("Turning Wi-Fi off", className); log("Turning Wi-Fi off", className);
QTimer::singleShot(0, this, SLOT(turnOffWifi())); QTimer::singleShot(0, this, SLOT(turnOffWifi()));
// To inform the Wi-Fi icon updater to not show the connected/failed to connect message // To inform the Wi-Fi icon updater to not show the connected/failed to connect message
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true"); writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;"); ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;");
ui->stopBtn->setEnabled(false); ui->stopBtn->setEnabled(false);
} }
@ -338,13 +338,13 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
} }
void wifiDialog::turnOnWifi() { void wifiDialog::turnOnWifi() {
string_writeconfig("/opt/ibxd", "toggle_wifi_on\n"); writeFile("/opt/ibxd", "toggle_wifi_on\n");
// No one will notice this freeze :> // No one will notice this freeze :>
waitToScan(); waitToScan();
} }
void wifiDialog::turnOffWifi() { void wifiDialog::turnOffWifi() {
string_writeconfig("/opt/ibxd", "toggle_wifi_off\n"); writeFile("/opt/ibxd", "toggle_wifi_off\n");
} }
void wifiDialog::on_logBtn_clicked() void wifiDialog::on_logBtn_clicked()

View file

@ -129,7 +129,7 @@ void wifilogger::getWifiInformation() {
if(waitingForFile == false) { if(waitingForFile == false) {
wifiInformationPath.remove(); wifiInformationPath.remove();
log("Sending get_wifi_information ibxd call", className); log("Sending get_wifi_information ibxd call", className);
string_writeconfig("/opt/ibxd", "get_wifi_information\n"); writeFile("/opt/ibxd", "get_wifi_information\n");
waitingForFile = true; waitingForFile = true;
} }