diff --git a/PKGBUILD b/PKGBUILD index b77682a..b685a70 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,22 +1,27 @@ -pkgname=dull +pkgname=dull-git pkgver=0.1 pkgrel=1 pkgdesc="Desktop app for securely storing sensitive files" arch=('x86_64') url="https://github.com/antpiasecki/dull" depends=('qt6-base' 'botan') -makedepends=('cmake') -source=("${url}/archive/refs/tags/${pkgver}.tar.gz") +makedepends=('cmake' 'git') +source=("git+${url}.git") sha256sums=('SKIP') options=('!debug') +pkgver() { + cd "${pkgname%-git}" + git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' +} + build() { - cd "${pkgname}-${pkgver}" + cd "${pkgname%-git}" cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr cmake --build build -j$(nproc) } package() { - cd "${pkgname}-${pkgver}/build" + cd "${pkgname%-git}/build" make DESTDIR="${pkgdir}" install } \ No newline at end of file diff --git a/src/crypto.h b/src/crypto.h index 60cd641..bbf784f 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -1,7 +1,6 @@ #pragma once #include "common.h" #include -#include #include namespace Crypto { diff --git a/src/main.cc b/src/main.cc index 6bd0704..980f26f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,4 @@ #include "mainwindow.h" -#include int main(int argc, char *argv[]) { QApplication app(argc, argv); diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 756cf3f..01c8123 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -1,7 +1,6 @@ // TODO: actual fs #include "mainwindow.h" #include -#include #include #include #include @@ -9,7 +8,6 @@ #include #include #include -#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(std::make_unique()) { @@ -22,12 +20,12 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->actionNew, &QAction::triggered, this, [this]() { QString path = QFileDialog::getSaveFileName(this, "Choose vault location", QDir::currentPath(), - "Dull Vaults (*.dull)"); + "Dull vaults (*.dull)"); if (path.isEmpty()) { return; } - if (!path.contains(".dull")) { + if (!path.endsWith(".dull")) { path += ".dull"; } @@ -112,6 +110,29 @@ MainWindow::MainWindow(QWidget *parent) ui->statusbar->showMessage("Added " + QString::number(paths.size()) + " files"); }); + + connect(ui->actionExtract_All, &QAction::triggered, this, [this]() { + if (!m_vault) { + return; + } + + QString path = + QFileDialog::getExistingDirectory(this, "Choose location to extract"); + if (path.isEmpty()) { + return; + } + + auto headers = m_vault->read_file_headers(); + for (const auto &header : headers) { + auto content = m_vault->read_file(header.name); + if (content) { + std::ofstream file(path.toStdString() + "/" + header.name, + std::ios::binary); + file.write(content->data(), static_cast(content->size())); + } + } + ui->statusbar->showMessage("Extracted all files to " + path); + }); } void MainWindow::reload_fs_tree() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 8ecdc17..04fbdac 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2,8 +2,6 @@ #include "ui_mainwindow.h" #include "vault.h" -#include -#include class MainWindow : public QMainWindow { Q_OBJECT diff --git a/src/mainwindow.ui b/src/mainwindow.ui index ff2dfcb..ca334d4 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -46,8 +46,8 @@ 0 0 - 800 - 32 + 900 + 30 @@ -65,6 +65,7 @@ Files + @@ -93,6 +94,14 @@ Add + + + + + + Extract All + + diff --git a/src/vault.cc b/src/vault.cc index 5ad7dc0..4469e2e 100644 --- a/src/vault.cc +++ b/src/vault.cc @@ -1,7 +1,6 @@ #include "vault.h" #include "common.h" #include "crypto.h" -#include #include #include