encfs improvements

This commit is contained in:
Nicolas Mailloux 2021-10-10 09:54:59 -04:00
parent b3da278096
commit fdc1f5d9c8
5 changed files with 191 additions and 7 deletions

View file

@ -66,5 +66,6 @@
<file>resources/check-display.png</file>
<file>resources/hourglass-bottom.png</file>
<file>resources/hourglass-top.png</file>
<file>resources/error.png</file>
</qresource>
</RCC>

View file

@ -24,9 +24,12 @@ encryptionManager::encryptionManager(QWidget *parent) :
ui->descriptionLabel->setStyleSheet("font-size: 9pt");
ui->successLabel->setStyleSheet("font-size: 15pt");
ui->successDescriptionLabel->setStyleSheet("font-size: 9pt");
ui->failureLabel->setStyleSheet("font-size: 15pt");
ui->failureDescriptionLabel->setStyleSheet("font-size: 9pt");
ui->setupContinueBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->setupAbortBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
ui->exitSuccessBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
ui->failureContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
@ -47,10 +50,22 @@ encryptionManager::encryptionManager(QWidget *parent) :
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->checkImageLabel->setPixmap(scaledPixmap);
}
{
stdIconWidth = sW / 1.65;
stdIconHeight = sH / 1.65;
QPixmap pixmap(":/resources/error.png");
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->failureImageLabel->setPixmap(scaledPixmap);
}
hourglassAnimationWidgetWindow = new hourglassAnimationWidget();
ui->hourglassWidget->insertWidget(0, hourglassAnimationWidgetWindow);
ui->hourglassWidget->setCurrentIndex(0);
setDefaultWorkDir();
if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true) {
setupPassphraseDialog(1);
}
}
encryptionManager::~encryptionManager()
@ -60,7 +75,16 @@ encryptionManager::~encryptionManager()
void encryptionManager::on_setupContinueBtn_clicked()
{
ui->activityWidget->setCurrentIndex(3);
setupPassphraseDialog(0);
}
void encryptionManager::setupPassphraseDialog(int mode) {
/*
* Mode can be:
* 0: Initial setup
* 1: Normal behavior
*/
ui->activityWidget->hide();
this->setStyleSheet("background-color: black");
global::keyboard::keyboardDialog = true;
global::keyboard::encfsDialog = true;
@ -68,7 +92,12 @@ void encryptionManager::on_setupContinueBtn_clicked()
generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupEncryptedStorage()));
if(mode == 0) {
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupEncryptedStorage()));
}
else {
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(unlockEncryptedStorage()));
}
connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
generalDialogWindow->show();
}
@ -125,6 +154,28 @@ void encryptionManager::setupEncryptedStorage() {
t->start();
}
void encryptionManager::unlockEncryptedStorage() {
this->setStyleSheet("background-color: white");
ui->activityWidget->show();
mkEncfsDirs();
std::string passphrase = global::encfs::passphrase.toStdString();
global::encfs::passphrase = "";
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_passphrase", passphrase);
bool exitStatus;
ui->activityWidget->setCurrentIndex(3);
QTimer * t = new QTimer(this);
t->setInterval(1000);
connect(t, &QTimer::timeout, [&]() {
if(QFile::exists("/external_root/run/encfs_mounted")) {
exitStatus = checkconfig("/external_root/run/encfs_mounted");
quit_restart();
}
} );
t->start();
}
void encryptionManager::mkEncfsDirs() {
QDir encfsDir;
QString encfsPath("/external_root/run/encfs");
@ -138,7 +189,9 @@ void encryptionManager::mkEncfsDirs() {
void encryptionManager::on_exitSuccessBtn_clicked()
{
setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "true");
quit_restart();
}
void encryptionManager::setupExitWidget(bool exitStatus) {
@ -152,7 +205,12 @@ void encryptionManager::setupExitWidget(bool exitStatus) {
}
setupExitWidgetRan = true;
}
else {
qDebug() << "setupExitWidgetRan";
}
}
void encryptionManager::on_failureContinueBtn_clicked()
{
setDefaultWorkDir();
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "true");
quit_restart();
}

View file

@ -29,6 +29,9 @@ private slots:
void mkEncfsDirs();
void on_exitSuccessBtn_clicked();
void setupExitWidget(bool exitStatus);
void on_failureContinueBtn_clicked();
void setupPassphraseDialog(int mode);
void unlockEncryptedStorage();
private:
Ui::encryptionManager *ui;

View file

@ -280,7 +280,129 @@ Would you like to enable it?</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3"/>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QLabel" name="failureLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>There was an error</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_13">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_14">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="failureContinueBtn">
<property name="text">
<string>Continue</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_15">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="failureDescriptionLabel">
<property name="text">
<string>Something wrong happened during the storage encryption process. Please try again later.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_16">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="failureImageLabel">
<property name="text">
<string>Failure image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer_17">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>

BIN
resources/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB