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

Use modern quick-adduid instead of "adduid" edit-key command

Apart from being less fragile than the edit-key interface using the
quick-* interface also removes the restrictions on the different
components of the user id. And it magically fixes the handling of
a canceled passphrase dialog.

GnuPG-bug-id: 5916
parent 69a36d04
......@@ -17,7 +17,7 @@
#include <Libkleo/Formatting>
#include <QGpgME/Protocol>
#include <QGpgME/AddUserIDJob>
#include <QGpgME/QuickJob>
#include <gpgme++/key.h>
......@@ -56,7 +56,7 @@ private:
private:
GpgME::Key key;
QPointer<AddUserIDDialog> dialog;
QPointer<QGpgME::AddUserIDJob> job;
QPointer<QGpgME::QuickJob> job;
};
AddUserIDCommand::Private *AddUserIDCommand::d_func()
......@@ -118,7 +118,6 @@ AddUserIDCommand::~AddUserIDCommand()
void AddUserIDCommand::doStart()
{
const std::vector<Key> keys = d->keys();
if (keys.size() != 1 ||
keys.front().protocol() != GpgME::OpenPGP ||
......@@ -147,11 +146,9 @@ void AddUserIDCommand::Private::slotDialogAccepted()
createJob();
if (!job) {
finished();
return;
}
else if (const Error err = job->start(key, dialog->name(), dialog->email())) {
showErrorDialog(err);
finished();
}
job->startAddUid(key, dialog->userID());
}
void AddUserIDCommand::Private::slotDialogRejected()
......@@ -197,12 +194,12 @@ void AddUserIDCommand::Private::createJob()
{
Q_ASSERT(!job);
const auto backend = (key.protocol() == GpgME::OpenPGP) ? QGpgME::openpgp() : QGpgME::smime();
const auto backend = QGpgME::openpgp();
if (!backend) {
return;
}
QGpgME::AddUserIDJob *const j = backend->addUserIDJob();
const auto j = backend->quickJob();
if (!j) {
return;
}
......
......@@ -225,3 +225,8 @@ QString AddUserIDDialog::email() const
{
return d->email();
}
QString AddUserIDDialog::userID() const
{
return d->ui.resultLabel->text();
}
......@@ -31,6 +31,11 @@ public:
void setEmail(const QString &email);
QString email() const;
/**
* Returns the user ID built from the entered name and/or email address.
*/
QString userID() const;
private:
class Private;
const std::unique_ptr<Private> d;
......
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