Encryption Manager working

This commit is contained in:
Nicolas Mailloux 2021-10-10 12:53:24 -04:00
parent fdc1f5d9c8
commit 997e62aed7
6 changed files with 20 additions and 11 deletions

View file

@ -64,7 +64,9 @@ encryptionManager::encryptionManager(QWidget *parent) :
setDefaultWorkDir(); setDefaultWorkDir();
if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true) { if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true) {
setupPassphraseDialog(1); ui->activityWidget->hide();
setupPassphraseDialogMode = 1;
QTimer::singleShot(1000, this, SLOT(setupPassphraseDialog()));
} }
} }
@ -75,12 +77,13 @@ encryptionManager::~encryptionManager()
void encryptionManager::on_setupContinueBtn_clicked() void encryptionManager::on_setupContinueBtn_clicked()
{ {
setupPassphraseDialog(0); setupPassphraseDialogMode = 0;
setupPassphraseDialog();
} }
void encryptionManager::setupPassphraseDialog(int mode) { void encryptionManager::setupPassphraseDialog() {
/* /*
* Mode can be: * setupPassphraseDialogMode can be:
* 0: Initial setup * 0: Initial setup
* 1: Normal behavior * 1: Normal behavior
*/ */
@ -92,7 +95,7 @@ void encryptionManager::setupPassphraseDialog(int mode) {
generalDialogWindow = new generalDialog(); generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen())); connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
if(mode == 0) { if(setupPassphraseDialogMode == 0) {
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupEncryptedStorage())); connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupEncryptedStorage()));
} }
else { else {
@ -121,7 +124,6 @@ void encryptionManager::refreshScreen() {
} }
void encryptionManager::showToast(QString messageToDisplay) { void encryptionManager::showToast(QString messageToDisplay) {
qDebug() << "showToast";
global::toast::message = messageToDisplay; global::toast::message = messageToDisplay;
toastWindow = new toast(this); toastWindow = new toast(this);
toastWindow->setAttribute(Qt::WA_DeleteOnClose); toastWindow->setAttribute(Qt::WA_DeleteOnClose);
@ -139,6 +141,8 @@ void encryptionManager::setupEncryptedStorage() {
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox"); string_writeconfig("/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"); string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase); string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
string_writeconfig("/opt/ibxd", "encfs_restart\n"); string_writeconfig("/opt/ibxd", "encfs_restart\n");
bool exitStatus; bool exitStatus;
ui->activityWidget->setCurrentIndex(3); ui->activityWidget->setCurrentIndex(3);
@ -161,8 +165,10 @@ void encryptionManager::unlockEncryptedStorage() {
std::string passphrase = global::encfs::passphrase.toStdString(); std::string passphrase = global::encfs::passphrase.toStdString();
global::encfs::passphrase = ""; global::encfs::passphrase = "";
string_writeconfig("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs"); string_writeconfig("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs");
string_writeconfig("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/books"); string_writeconfig("/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");
string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase); string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
string_writeconfig("/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);
@ -185,6 +191,7 @@ void encryptionManager::mkEncfsDirs() {
dumpDir.mkpath(dumpPath); dumpDir.mkpath(dumpPath);
QDir decDir; QDir decDir;
QString decPath("/mnt/onboard/onboard/encfs-decrypted"); QString decPath("/mnt/onboard/onboard/encfs-decrypted");
decDir.mkpath(decPath);
} }
void encryptionManager::on_exitSuccessBtn_clicked() void encryptionManager::on_exitSuccessBtn_clicked()

View file

@ -18,6 +18,7 @@ public:
explicit encryptionManager(QWidget *parent = nullptr); explicit encryptionManager(QWidget *parent = nullptr);
~encryptionManager(); ~encryptionManager();
bool setupExitWidgetRan = false; bool setupExitWidgetRan = false;
int setupPassphraseDialogMode;
private slots: private slots:
void on_setupContinueBtn_clicked(); void on_setupContinueBtn_clicked();
@ -30,7 +31,7 @@ private slots:
void on_exitSuccessBtn_clicked(); void on_exitSuccessBtn_clicked();
void setupExitWidget(bool exitStatus); void setupExitWidget(bool exitStatus);
void on_failureContinueBtn_clicked(); void on_failureContinueBtn_clicked();
void setupPassphraseDialog(int mode); void setupPassphraseDialog();
void unlockEncryptedStorage(); void unlockEncryptedStorage();
private: private:

View file

@ -75,7 +75,7 @@
<item row="5" column="0"> <item row="5" column="0">
<widget class="QLabel" name="descriptionLabel"> <widget class="QLabel" name="descriptionLabel">
<property name="text"> <property name="text">
<string>Encrypted storage permits you to keep your most important files and data safe from anyone else than you. <string>Encrypted storage allows you to keep your most important files and data safe from anyone else than you.
Would you like to enable it?</string> Would you like to enable it?</string>
</property> </property>
<property name="alignment"> <property name="alignment">

View file

@ -32,7 +32,7 @@ hourglassAnimationWidget::hourglassAnimationWidget(QWidget *parent) :
ui->hourglassBottomLabel->setPixmap(scaledPixmap); ui->hourglassBottomLabel->setPixmap(scaledPixmap);
} }
int i = 0; i = 0;
QTimer * t = new QTimer(); QTimer * t = new QTimer();
t->setInterval(500); t->setInterval(500);
connect(t, &QTimer::timeout, [&]() { connect(t, &QTimer::timeout, [&]() {

View file

@ -14,6 +14,7 @@ class hourglassAnimationWidget : public QWidget
public: public:
explicit hourglassAnimationWidget(QWidget *parent = nullptr); explicit hourglassAnimationWidget(QWidget *parent = nullptr);
~hourglassAnimationWidget(); ~hourglassAnimationWidget();
int i;
private: private:
Ui::hourglassAnimationWidget *ui; Ui::hourglassAnimationWidget *ui;

View file

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
if(checkconfig_str_val.isEmpty() == true) { if(checkconfig_str_val.isEmpty() == true) {
string_writeconfig(".config/18-encrypted_storage/status", "true"); string_writeconfig(".config/18-encrypted_storage/status", "true");
} }
if(checkconfig(".config/18-encrypted_storage/status") == true and checkconfig("/run/encfs_mounted") == false) { if(checkconfig(".config/18-encrypted_storage/status") == true and checkconfig("/external_root/run/encfs_mounted") == false) {
// Open Encryption Manager to unlock encrypted storage // Open Encryption Manager to unlock encrypted storage
QApplication a(argc, argv); QApplication a(argc, argv);
encryptionManager w; encryptionManager w;