QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
passbackendfactory.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#ifndef SRC_PASSBACKENDFACTORY_H_
9#define SRC_PASSBACKENDFACTORY_H_
10
11#include "imitatepass.h"
12#include "realpass.h"
13
14#include <QScopedPointer>
15
16class Pass;
17
30public:
37 static auto getPass() -> Pass *;
42 static auto getRealPass() -> RealPass *;
47 static auto getImitatePass() -> ImitatePass *;
54 static void invalidate();
61 static auto isIdle() -> bool;
62
63private:
68 static Pass *pass;
69 // Go via pointer to avoid dynamic initialization, due to "random"
70 // initialization order relative to other globals, especially around QObject
71 // metadata dynamic initialization can lead to crashes depending on compiler,
72 // linker etc.
74 static QScopedPointer<RealPass> realPass;
76 static QScopedPointer<ImitatePass> imitatePass;
77
79 PassBackendFactory() = default;
80};
81
82#endif // SRC_PASSBACKENDFACTORY_H_
Implementation that imitates 'pass' when the real tool is unavailable.
Definition imitatepass.h:40
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()....
PassBackendFactory()=default
Not constructible; the class has only static members.
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
Implementation of Pass that wraps the 'pass' command-line tool.
Definition realpass.h:32
ImitatePass, the backend that does what pass does by running gpg and git itself.
RealPass, the backend that hands every store operation to the pass command-line tool.