QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
FirstRunWizard Class Reference

The first start of QtPass: find GnuPG (and pass and Git), make sure there is a secret key, pick or create the password store. Replaces the chain of message boxes ConfigDialog::wizard() used to run before showing the whole configuration dialog. More...

#include <firstrunwizard.h>

Inheritance diagram for FirstRunWizard:
Collaboration diagram for FirstRunWizard:

Public Types

enum  Page {
  IntroPage , ProgramsPage , KeyPage , StorePage ,
  DonePage
}
 Page ids, in order. More...

Public Member Functions

 FirstRunWizard (QWidget *parent=nullptr)
 Build the wizard from the current settings.
auto settings () const -> AppSettings
 The settings as the pages have edited them so far.
void accept () override
 Write the settings and, when the chosen store has no .gpg-id yet, create and initialise it for the chosen keys first.

Static Public Member Functions

static auto secretKeys (const QString &gpgExecutable, QString *problem=nullptr) -> QList< UserInfo >
 The secret keys gpg lists for gpgExecutable.
static auto isStore (const QString &path) -> bool
 Whether path points at an initialised store.

Private Member Functions

auto initialiseStore (const QString &store) -> bool
 Make store a password store for the ticked keys: create the folder when it is missing, write and sign its .gpg-id, and set up Git when chosen. On failure what was written is taken back, so a second Finish runs the whole initialisation again.
auto initialiseGit (const QString &store) -> bool
 Give an existing store the Git repository it was chosen to have.

Private Attributes

AppSettings m_settings
bool m_detectChoices = false
QList< UserInfo > m_keys

Friends

class ProgramsWizardPage
class KeyWizardPage
class StoreWizardPage
class DoneWizardPage

Detailed Description

The first start of QtPass: find GnuPG (and pass and Git), make sure there is a secret key, pick or create the password store. Replaces the chain of message boxes ConfigDialog::wizard() used to run before showing the whole configuration dialog.

The wizard works on a copy of the settings and writes it back on Finish, after it has created and initialised the store when that was needed (ProfileInit). Cancel leaves the settings as they were; the caller keeps asking until the configuration is usable or the user gives up.

Definition at line 37 of file firstrunwizard.h.

Member Enumeration Documentation

◆ Page

Page ids, in order.

Enumerator
IntroPage 

What QtPass is and what the wizard will do.

ProgramsPage 

ProgramsWizardPage: where gpg, pass and git are.

KeyPage 

KeyWizardPage: the secret keys, with generation.

StorePage 

StoreWizardPage: the store folder and the Git choice.

DonePage 

DoneWizardPage: summary and two preferences.

Definition at line 77 of file firstrunwizard.h.

Constructor & Destructor Documentation

◆ FirstRunWizard()

FirstRunWizard::FirstRunWizard ( QWidget * parent = nullptr)
explicit

Build the wizard from the current settings.

Parameters
parentThe main window.

Definition at line 72 of file firstrunwizard.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ accept()

void FirstRunWizard::accept ( )
override

Write the settings and, when the chosen store has no .gpg-id yet, create and initialise it for the chosen keys first.

Definition at line 197 of file firstrunwizard.cpp.

Here is the call graph for this function:

◆ initialiseGit()

auto FirstRunWizard::initialiseGit ( const QString & store) -> bool
private

Give an existing store the Git repository it was chosen to have.

Parameters
storeThe folder, cleaned.
Returns
Whether the repository is ready (the user was told otherwise).

Definition at line 185 of file firstrunwizard.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseStore()

auto FirstRunWizard::initialiseStore ( const QString & store) -> bool
private

Make store a password store for the ticked keys: create the folder when it is missing, write and sign its .gpg-id, and set up Git when chosen. On failure what was written is taken back, so a second Finish runs the whole initialisation again.

Parameters
storeThe folder, cleaned.
Returns
Whether the store is ready (the user was told otherwise).

Definition at line 140 of file firstrunwizard.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isStore()

auto FirstRunWizard::isStore ( const QString & path) -> bool
static

Whether path points at an initialised store.

Parameters
pathA directory.
Returns
true when it holds a .gpg-id.

Definition at line 135 of file firstrunwizard.cpp.

Here is the caller graph for this function:

◆ secretKeys()

auto FirstRunWizard::secretKeys ( const QString & gpgExecutable,
QString * problem = nullptr ) -> QList< UserInfo >
static

The secret keys gpg lists for gpgExecutable.

gpg exits with 2 after a complete listing when one key holds something it cannot handle (a subkey of an unknown algorithm, say): the keys it listed are taken, and what it reported goes to problem. Any other failure lists no keys.

Parameters
gpgExecutableThe gpg binary.
problemReceives gpg's error output when it did not exit cleanly, cut to a few hundred characters and made displayable (Util::displayable()); null to not care.
Returns
The keys, or an empty list when gpg cannot run or failed.

Definition at line 105 of file firstrunwizard.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ settings()

auto FirstRunWizard::settings ( ) const -> AppSettings
inline

The settings as the pages have edited them so far.

Returns
A copy.

Definition at line 51 of file firstrunwizard.h.

◆ DoneWizardPage

friend class DoneWizardPage
friend

Definition at line 111 of file firstrunwizard.h.

◆ KeyWizardPage

friend class KeyWizardPage
friend

Definition at line 109 of file firstrunwizard.h.

◆ ProgramsWizardPage

friend class ProgramsWizardPage
friend

Definition at line 108 of file firstrunwizard.h.

◆ StoreWizardPage

friend class StoreWizardPage
friend

Definition at line 110 of file firstrunwizard.h.

Member Data Documentation

◆ m_detectChoices

bool FirstRunWizard::m_detectChoices = false
private

Whether nothing was chosen yet (SettingsConstants::firstRunPending): only then are "Use pass" and "Use Git" turned on from what is detected. The wizard also runs again for a store that lost its recipient list, and then shows the choices saved before.

Definition at line 120 of file firstrunwizard.h.

◆ m_keys

QList<UserInfo> FirstRunWizard::m_keys
private

The secret keys as listed on the key page; the enabled ones become the recipients of a new store.

Definition at line 123 of file firstrunwizard.h.

◆ m_settings

AppSettings FirstRunWizard::m_settings
private

The pages' working copy of the settings, loaded in the constructor and saved by accept(); the pages edit it through their friend access.

Definition at line 115 of file firstrunwizard.h.


The documentation for this class was generated from the following files: