diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3fae23e..08b0bf5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -56,7 +56,12 @@ MainWindow::MainWindow(QWidget *parent) : ui->memoTxtChat->setPlaceholderText("Send Message"); ui->memoTxtChat->setTextColor(Qt::white); - + + // Check for encryption + if(fileExists(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("addresslabels.dat.enc"))) + { + this->removeWalletEncryption(); + } // Status Bar setupStatusBar(); @@ -185,6 +190,12 @@ MainWindow::MainWindow(QWidget *parent) : createWebsocket(wormholecode); } } + +bool MainWindow::fileExists(QString path) +{ + QFileInfo check_file(path); + return (check_file.exists() && check_file.isFile()); +} void MainWindow::createWebsocket(QString wormholecode) { qDebug() << "Listening for app connections on port 8777"; @@ -332,6 +343,7 @@ void MainWindow::removeWalletEncryption() { auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); QString target_enc_file = dir.filePath("addresslabels.dat.enc"); QString target_dec_file = dir.filePath("addresslabels.dat"); + FileEncryption::decrypt(target_dec_file, target_enc_file, key); d.exec(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 85f4feb..9a6f02f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -100,6 +100,7 @@ private slots: private: + bool fileExists(QString path); void closeEvent(QCloseEvent* event);