8#ifndef SRC_IMPORTKEYDIALOG_H_
9#define SRC_IMPORTKEYDIALOG_H_
12#include <QElapsedTimer>
13#include <QScopedPointer>
113 [[nodiscard]]
static auto fitsTheEditor(QStringView text) -> bool;
146 QScopedPointer<Ui::ImportKeyDialog>
ui;
178 auto runGpg(
const QStringList &args,
const QString &input, QString *stdOut,
179 QString *stdErr,
const QElapsedTimer &timer) -> bool;
static constexpr qsizetype kMaxKeyLines
Most lines fitsTheEditor() lets through: a 16 MiB key file in armor's 64-character lines.
static auto fitsTheEditor(QStringView text) -> bool
Whether text is laid out as armor can be, so the input field can show it at a bounded cost.
~ImportKeyDialog() override
Destroys the dialog and its generated UI.
static auto parseGpgImportOutput(const QString &output) -> QString
Parse GPG import output to extract a key id or fingerprint.
void showError(const QString &message)
Shows message in a plain-text warning box (gpg's stderr quotes user IDs, which must not be read as ma...
auto importedKeyId() const -> QString
Get the imported key id on success.
static auto keysInBlock(const QString &listing) -> BlockKeys
Count the keys in the listing of gpg --with-colons --import-options show-only --import.
int m_timeoutMs
Most milliseconds gpg may take to import (kImportTimeoutMs).
QString m_importedKeyId
Key id or fingerprint of the last successful import; empty until then. Read back through importedKeyI...
ImportKeyDialog(QString gpgExe, QWidget *parent=nullptr, int timeoutMs=kImportTimeoutMs)
Construct an ImportKeyDialog.
void on_fileButton_clicked()
"From file" button: picks a file, reads it as a regular file of at most 16 MiB, requires the -----BEG...
static constexpr int kImportTimeoutMs
How long gpg may take to import before it is stopped: the import runs on the GUI thread,...
auto runGpg(const QStringList &args, const QString &input, QString *stdOut, QString *stdErr, const QElapsedTimer &timer) -> bool
Runs gpg with args on input within what is left of m_timeoutMs since timer started.
QString m_gpgExe
Path of the gpg binary to run; empty means plain gpg on PATH.
void on_pasteButton_clicked()
"From clipboard" button: replaces the input field with the clipboard text, unless the clipboard is em...
void showSuccess(const QString &keyId)
Shows the "imported, now verify the fingerprint" information box.
QScopedPointer< Ui::ImportKeyDialog > ui
Generated form (importkeydialog.ui); owned.
auto importFromString(const QString &input) -> bool
Lists the keys in input first, with nothing written, and refuses a block that holds a private key or ...
void on_importButton_clicked()
"Import" button: runs importFromString() on the trimmed input and closes the dialog with accept() on ...
static constexpr qsizetype kMaxKeyLine
Longest line fitsTheEditor() lets through, in characters.
void on_inputTextEdit_textChanged()
Enables the Import button only while the input field holds non-blank text.
How many keys an armored block holds, by kind.
int publicKeys
Public keys: pub records.
int secretKeys
Keys with their secret part: sec records.