QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
processinfo.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#include "processinfo.h"
9#include <QString>
10
11#include <array>
12
13namespace Enums {
14
15namespace {
16
24constexpr std::array kTable{
25 ProcessInfo{"git init", false}, // GIT_INIT // no-tr
26 ProcessInfo{"git add", false}, // GIT_ADD // no-tr
27 ProcessInfo{"git commit", false}, // GIT_COMMIT // no-tr
28 ProcessInfo{"git rm", false}, // GIT_RM // no-tr
29 ProcessInfo{"git pull", false}, // GIT_PULL // no-tr
30 ProcessInfo{"git push", false}, // GIT_PUSH // no-tr
31 ProcessInfo{"", true}, // PASS_SHOW: the decrypted entry
32 ProcessInfo{"pass insert",
33 true}, // PASS_INSERT: the entry being written // no-tr
34 ProcessInfo{"pass rm", false}, // PASS_REMOVE // no-tr
35 ProcessInfo{"pass init", false}, // PASS_INIT // no-tr
36 ProcessInfo{"gpg --gen-key", false}, // GPG_GENKEYS // no-tr
37 ProcessInfo{"pass mv", false}, // PASS_MOVE // no-tr
38 ProcessInfo{"pass cp", false}, // PASS_COPY // no-tr
39 ProcessInfo{"git mv", false}, // GIT_MOVE // no-tr
40 // ImitatePass::Copy literally invokes `git cp` (a git-extras
41 // subcommand), so the label matches what is run. Stock-git users without
42 // git-extras see the underlying "'cp' is not a git command" failure in
43 // the process output panel.
44 ProcessInfo{"git cp", false}, // GIT_COPY // no-tr
45 ProcessInfo{"pass grep", true}, // PASS_GREP: hits inside entries // no-tr
46};
47
48// The extent comes from the rows, not from PROCESS_COUNT: a table declared
49// as PROCESS_COUNT long would value-initialise a missing row into
50// {nullptr, false}, and a new process kind would be broadcast as harmless.
51static_assert(kTable.size() == static_cast<std::size_t>(PROCESS_COUNT),
52 "every PROCESS needs a label and a secrecy decision");
53
54constexpr ProcessInfo kNotAProcess{"", false};
55
56} // namespace
57
58auto processInfo(PROCESS pid) -> const ProcessInfo & {
59 if (pid < 0 || pid >= PROCESS_COUNT) {
60 return kNotAProcess;
61 }
62 return kTable.at(static_cast<std::size_t>(pid));
63}
64
65auto processLabel(PROCESS pid) -> QString {
66 return QString::fromLatin1(processInfo(pid).label);
67}
68
69} // namespace Enums
Enumerators for QtPass configuration and runtime operations.
auto processLabel(PROCESS pid) -> QString
The command label for pid, as the output panel shows it.
PROCESS
Identifies different subprocess operations used in QtPass.
Definition enums.h:43
@ PROCESS_COUNT
Definition enums.h:62
auto processInfo(PROCESS pid) -> const ProcessInfo &
What is known about pid.
Enums::ProcessInfo, the one table that names each kind of subprocess and says whether its output may ...
What QtPass knows about one kind of subprocess: what to call it and whether its output may carry a se...
Definition processinfo.h:28