encfs: Open dialog if files present in dropbox

This commit is contained in:
Nicolas Mailloux 2021-12-31 15:50:59 -05:00
parent e310dd14b3
commit 57f99c0fe2
5 changed files with 35 additions and 5 deletions

View file

@ -101,6 +101,7 @@ namespace global {
inline bool enableStorageEncryptionDialog; inline bool enableStorageEncryptionDialog;
inline bool disableStorageEncryptionDialog; inline bool disableStorageEncryptionDialog;
inline bool errorNoBooksInDropboxDialog; inline bool errorNoBooksInDropboxDialog;
inline bool repackDialog;
} }
namespace library { namespace library {
inline unsigned long bookId; inline unsigned long bookId;

View file

@ -159,6 +159,13 @@ generalDialog::generalDialog(QWidget *parent) :
ui->bodyLabel->setText("Please put books in the 'encfs-dropbox' folder to repack your encrypted storage."); ui->bodyLabel->setText("Please put books in the 'encfs-dropbox' folder to repack your encrypted storage.");
this->adjustSize(); this->adjustSize();
} }
else if(global::encfs::repackDialog == true) {
ui->headerLabel->setText("Information");
ui->okBtn->setText("Proceed");
ui->cancelBtn->setText("Not now");
ui->bodyLabel->setText("New files have been found in the 'encfs-dropbox' folder. Would you want to repack your encrypted storage with them?");
this->adjustSize();
}
else { else {
// We shouldn't be there ;) // We shouldn't be there ;)
; ;
@ -216,6 +223,9 @@ void generalDialog::on_cancelBtn_clicked()
else if(global::encfs::errorNoBooksInDropboxDialog == true) { else if(global::encfs::errorNoBooksInDropboxDialog == true) {
global::encfs::errorNoBooksInDropboxDialog = false; global::encfs::errorNoBooksInDropboxDialog = false;
} }
else if(global::encfs::repackDialog == true) {
global::encfs::repackDialog = false;
}
generalDialog::close(); generalDialog::close();
} }
} }
@ -455,6 +465,11 @@ void generalDialog::on_okBtn_clicked()
emit disableStorageEncryption(); emit disableStorageEncryption();
this->close(); this->close();
} }
if(global::encfs::repackDialog == true) {
global::encfs::repackDialog = false;
string_writeconfig("/external_root/run/encfs_repack", "true");
quit_restart();
}
} }
void generalDialog::on_acceptBtn_clicked() void generalDialog::on_acceptBtn_clicked()
{ {
@ -585,3 +600,13 @@ void generalDialog::showToastNative(QString messageToDisplay) {
void generalDialog::closeIndefiniteToastNative() { void generalDialog::closeIndefiniteToastNative() {
emit closeIndefiniteToast(); emit closeIndefiniteToast();
} }
void generalDialog::quit_restart() {
// If existing, cleaning bookconfig_mount mountpoint
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
// Restarting InkBox
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}

View file

@ -57,6 +57,7 @@ private slots:
void openBookFileNative(QString book, bool relativePath); void openBookFileNative(QString book, bool relativePath);
void showToastNative(QString messageToDisplay); void showToastNative(QString messageToDisplay);
void closeIndefiniteToastNative(); void closeIndefiniteToastNative();
void quit_restart();
private: private:
Ui::generalDialog *ui; Ui::generalDialog *ui;

View file

@ -378,8 +378,8 @@ MainWindow::MainWindow(QWidget *parent)
// If new files are found in /mnt/onboard/onboard/encfs-dropbox, ask if user wants to encrypt them // If new files are found in /mnt/onboard/onboard/encfs-dropbox, ask if user wants to encrypt them
if(checkconfig(".config/18-encrypted_storage/status") == true) { if(checkconfig(".config/18-encrypted_storage/status") == true) {
QDir encfsDropboxDir("/mnt/onboard/onboard/encfs-dropbox"); QDir encfsDropboxDir("/mnt/onboard/onboard/encfs-dropbox");
if(encfsDropboxDir.isEmpty()) { if(!encfsDropboxDir.isEmpty()) {
QTimer::singleShot(1000, this, SLOT(openEncfsEncryptDialog())); QTimer::singleShot(1000, this, SLOT(openEncfsRepackDialog()));
} }
} }
@ -1041,8 +1041,11 @@ void MainWindow::checkForUpdate() {
} }
} }
void MainWindow::openEncfsEncryptDialog() { void MainWindow::openEncfsRepackDialog() {
global::encfs::repackDialog = true;
generalDialogWindow = new generalDialog(this);
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
generalDialogWindow->show();
} }
void MainWindow::on_libraryButton_clicked() void MainWindow::on_libraryButton_clicked()

View file

@ -89,7 +89,7 @@ private slots:
void openBookFile(QString book, bool relativePath); void openBookFile(QString book, bool relativePath);
void openReaderFramework(); void openReaderFramework();
void checkForUpdate(); void checkForUpdate();
void openEncfsEncryptDialog(); void openEncfsRepackDialog();
void on_libraryButton_clicked(); void on_libraryButton_clicked();