QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
passbackendfactory.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
9
10#include "passbackendfactory.h"
11#include "appsettings.h"
12#include "pass.h"
13#include "qtpasssettings.h"
14#include "util.h"
15
16#include <QDir>
17
19QScopedPointer<RealPass> PassBackendFactory::realPass;
20QScopedPointer<ImitatePass> PassBackendFactory::imitatePass;
21
23 if (!pass) {
25 // Ensure store directory exists (first-run side effect — load() normalises
26 // the path but does not create the directory).
27 if (!QDir(s.passStore).exists())
29 if (s.usePass) {
30 pass = getRealPass();
31 } else {
33 }
34 if (pass) {
35 pass->init(s);
36 }
37 }
38 return pass;
39}
40
42 if (realPass.isNull()) {
43 realPass.reset(new RealPass());
44 }
45 return realPass.data();
46}
47
49 if (imitatePass.isNull()) {
50 imitatePass.reset(new ImitatePass());
52 imitatePass->init(s);
53 }
54 return imitatePass.data();
55}
56
58 return (realPass.isNull() || realPass->isIdle()) &&
59 (imitatePass.isNull() || imitatePass->isIdle());
60}
61
AppSettings, the value object holding every flat QtPass setting.
Implementation that imitates 'pass' when the real tool is unavailable.
Definition imitatepass.h:40
ImitatePass()
Construct the backend and connect its content search.
static auto getPass() -> Pass *
Get the active backend, constructing and initialising it on first use after construction or invalidat...
static QScopedPointer< ImitatePass > imitatePass
The gpg and git backend, constructed on first use.
static Pass * pass
The backend getPass() last selected; null until the first call and again after invalidate()....
static auto getRealPass() -> RealPass *
Get the lazily-constructed RealPass backend.
static QScopedPointer< RealPass > realPass
The pass backend, constructed on first use.
static auto isIdle() -> bool
Whether neither backend runs or waits for anything: after a switch of backend the previous one is kep...
static auto getImitatePass() -> ImitatePass *
Get the lazily-constructed ImitatePass backend.
static void invalidate()
Forget the currently active backend.
Abstract base class for password store operations.
Definition pass.h:75
static auto load() -> AppSettings
Load all flat settings into an AppSettings value object.
Implementation of Pass that wraps the 'pass' command-line tool.
Definition realpass.h:32
RealPass()
Construct a RealPass instance.
Definition realpass.cpp:36
static auto mkpathForStore(const QString &path) -> bool
Create path and any missing parents as pass would.
Definition util.cpp:438
Pass, the abstract password-store backend that RealPass and ImitatePass implement,...
PassBackendFactory, which constructs the two Pass backends on demand and hands out the one the settin...
QtPassSettings, the QSettings singleton behind every saved setting, the profiles and the Pass backend...
Plain value-object holding all flat QtPass configuration.
Definition appsettings.h:36
bool usePass
Use the pass CLI (true) or native git/gpg.
Definition appsettings.h:59
QString passStore
Password-store root path.
Definition appsettings.h:60
Util: static helpers for the process environment, binary discovery, store paths, URL safety and the l...