PasswordImportDialog

1. Overview

The PasswordImportDialog.cpp file is a Bulk password-import dialog implementation in BastionGuard.

Builds the import workflow, loads and previews browser CSV records, prepares vault entries, processes them in a worker thread, and marshals progress/completion updates to GTK.

The documentation below is generated from the supplied source and covers its API surface, runtime responsibilities, data flow, filesystem or command interactions, concurrency model, and security considerations.


2. Source Inventory

  • Original path: password_manager/PasswordImportDialog.cpp
  • Language: C++
  • Source type: .cpp
  • Line count: 334
  • SHA-256: 8536b815e07198a4ec138c56f9479eb53d6906d55eb1f16a76621940598374d4

3. Dependencies

The file declares the following compile-time dependencies:

Project

  • PasswordImportDialog.hpp
  • PasswordImporter.hpp

GTK/GLib

  • glibmm/i18n.h

C/C++ Runtime

  • fstream
  • sstream

4. Types and Public Contract

No standalone class, structure, or enumeration is declared directly in this file.


5. API and Method Inventory

The following functions or methods are implemented in this file:

  • PasswordImportDialog::PasswordImportDialog(Gtk::Window& parent) – Implements the operation represented by this API.
  • PasswordImportDialog::~PasswordImportDialog() – Releases callbacks, threads, timers, or other owned runtime state.
  • PasswordImportDialog::present() – Presents the associated dialog or window.
  • PasswordImportDialog::hide() – Hides the associated dialog.
  • PasswordImportDialog::buildUi() – Constructs the corresponding GTK interface section.
  • sigc::mem_fun(*this, &PasswordImportDialog::onChooseFile)); importBtn_.signal_clicked().connect( sigc::mem_fun(*this, &PasswordImportDialog::onImportClicked)); dialog_->signal_response().connect([this](int r) – Implements the operation represented by this API.
  • PasswordImportDialog::styleImportButton() – Implements the operation represented by this API.
  • PasswordImportDialog::onChooseFile() – Handles the on choose file user-interface action.
  • PasswordImportDialog::loadFile(const std::string& path) – Parses a selected import file and updates preview state.
  • PasswordImportDialog::onProgressTick() – Handles the on progress tick user-interface action.
  • PasswordImportDialog::signal_import_confirmed() – Implements the operation represented by this API.
  • parent_(parent), mainBox_(Gtk::Orientation::VERTICAL, 10), hintLabel_(_("Seleziona un file CSV esportato da Chrome, Edge, Firefox o Safari.")), chooseFileBtn_(_("📂 Scegli file CSV…")), progressBox_(Gtk::Orientation::VERTICAL, 4), importBtn_(_("⬆ Importa credenziali")) – Implements the operation represented by this API.

6. Functional Architecture

Import Workflow

  • Selects browser-exported CSV files through a GTK file chooser.
  • Displays detected record count and a preview list before confirmation.
  • Converts imported credentials into vault entries and generates identifiers/timestamps before emission.
  • Reports worker progress using atomics and Glib::Dispatcher.

Concurrency

  • Maintains a dedicated import thread and joins it during destruction when necessary.
  • Keeps GTK operations on the main thread through dispatcher callbacks.
  • Prevents duplicate import starts through an atomic importing_ flag.

7. Operational Flow

  1. Select and read a browser-exported CSV file.
  2. Normalize encoding and line endings, then detect the browser format.
  3. Parse rows while honoring CSV quoting rules.
  4. Preview normalized credentials and convert them into vault entries.
  5. Emit or store the bulk records and report completion.

8. Filesystem and External Command Surface

No hard-coded absolute filesystem path is declared directly in this file.

Commands or Security Primitives Referenced

  • ip
  • sh

9. Concurrency and Lifecycle

  • Uses worker threads for operations that could block the GTK main loop.

10. Security Considerations

  • Password metadata and encrypted secrets are separated, reducing accidental exposure through the index file.
  • Cleartext passwords exist in process memory while the vault is unlocked and during import/export workflows.
  • CSV import and export files are unencrypted and must be handled as sensitive data.
  • Background callbacks must not outlive their owning GTK objects.

11. Implementation Considerations

  • The implementation should remain synchronized with the matching header declarations.

12. Licensing and Branding

The source is distributed under the GNU General Public License version 3.

The source header identifies BastionGuard™ as a trademark and states that the name and branding are not licensed under the GPL.

The software is provided without warranty, including implied warranties of merchantability or fitness for a particular purpose.