Commit d19de25b authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Make the EmptyPassphraseProvider available to other classes

GnuPG-bug-id: 5832
parent a2bc1fec
......@@ -417,6 +417,8 @@ set(_kleopatra_SRCS
utils/dragqueen.h
utils/email.cpp
utils/email.h
utils/emptypassphraseprovider.cpp
utils/emptypassphraseprovider.h
utils/filedialog.cpp
utils/filedialog.h
utils/gui-helper.cpp
......
......@@ -37,7 +37,6 @@
#include <QVBoxLayout>
#include <gpgme++/context.h>
#include <gpgme++/interfaces/passphraseprovider.h>
#include <gpgme++/keygenerationresult.h>
#include "kleopatra_debug.h"
......@@ -46,16 +45,6 @@ using namespace Kleo;
using namespace Kleo::NewCertificateUi;
using namespace GpgME;
class KeyCreationPage::EmptyPassphraseProvider: public PassphraseProvider
{
public:
char *getPassphrase(const char * /*useridHint*/, const char * /*description*/,
bool /*previousWasBad*/, bool &/*canceled*/) override
{
return gpgrt_strdup ("");
}
};
struct KeyCreationPage::UI
{
UI(QWizardPage *parent)
......@@ -73,7 +62,6 @@ struct KeyCreationPage::UI
KeyCreationPage::KeyCreationPage(QWidget *p)
: WizardPage{p}
, ui{new UI{this}}
, mEmptyPWProvider{new EmptyPassphraseProvider}
{
setObjectName(QString::fromUtf8("Kleo__NewCertificateUi__KeyCreationPage"));
}
......@@ -102,7 +90,7 @@ void KeyCreationPage::startJob()
}
if (!protectedKey() && pgp()) {
auto ctx = QGpgME::Job::context(j);
ctx->setPassphraseProvider(mEmptyPWProvider.get());
ctx->setPassphraseProvider(&mEmptyPassphraseProvider);
ctx->setPinentryMode(Context::PinentryLoopback);
}
connect(j, &QGpgME::KeyGenerationJob::result,
......
......@@ -15,6 +15,8 @@
#include "wizardpage_p.h"
#include "utils/emptypassphraseprovider.h"
namespace GpgME
{
class KeyGenerationResult;
......@@ -52,7 +54,6 @@ private:
struct UI;
std::unique_ptr<UI> ui;
class EmptyPassphraseProvider;
std::unique_ptr<EmptyPassphraseProvider> mEmptyPWProvider;
EmptyPassphraseProvider mEmptyPassphraseProvider;
QPointer<QGpgME::KeyGenerationJob> job;
};
/* -*- mode: c++; c-basic-offset:4 -*-
utils/emptypassphraseprovider.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2016, 2017 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "emptypassphraseprovider.h"
#include <gpg-error.h>
char *EmptyPassphraseProvider::getPassphrase(const char *, const char *, bool , bool &)
{
return gpgrt_strdup("");
}
/* -*- mode: c++; c-basic-offset:4 -*-
utils/emptypassphraseprovider.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2016, 2017 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <gpgme++/interfaces/passphraseprovider.h>
class EmptyPassphraseProvider: public GpgME::PassphraseProvider
{
public:
char *getPassphrase(const char *useridHint, const char *description, bool previousWasBad, bool &canceled) override;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment