qt: Support changing expiry of subkeys
* lang/qt/src/changeexpiryjob.h (ChangeExpiryJob::start): New overload that accepts subkeys (with empty implementation). * lang/qt/src/qgpgmechangeexpiryjob.h, lang/qt/src/qgpgmechangeexpiryjob.cpp (QGpgMEChangeExpiryJob::start): New overload that accepts subkeys. -- This adds the possibility to change the expiry of subkeys. GnuPG-bug-id: 4717
This commit is contained in:
parent
c813734c9c
commit
4f2cd3a0c6
3
NEWS
3
NEWS
@ -6,6 +6,9 @@ Noteworthy changes in version 1.14.1 (unreleased)
|
|||||||
|
|
||||||
* cpp: Support for set expire operations in the C++ bindings. [#5003]
|
* cpp: Support for set expire operations in the C++ bindings. [#5003]
|
||||||
|
|
||||||
|
* qt: Extended ChangeExpiryJob to support changing the expiry of
|
||||||
|
subkeys. [#4717]
|
||||||
|
|
||||||
* Interface changes relative to the 1.14.0 release:
|
* Interface changes relative to the 1.14.0 release:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
gpgme_op_setexpire_start NEW.
|
gpgme_op_setexpire_start NEW.
|
||||||
|
@ -37,10 +37,17 @@
|
|||||||
|
|
||||||
#include "job.h"
|
#include "job.h"
|
||||||
|
|
||||||
|
#ifdef BUILDING_QGPGME
|
||||||
|
# include "key.h"
|
||||||
|
#else
|
||||||
|
# include <gpgme++/key.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace GpgME
|
namespace GpgME
|
||||||
{
|
{
|
||||||
class Error;
|
class Error;
|
||||||
class Key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
@ -76,6 +83,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) = 0;
|
virtual GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Starts the change-expiry operation. \a key is the key to change,
|
||||||
|
\a subkeys is a list of subkeys of the key, and \a expiry is the
|
||||||
|
new expiry time. If \a subkeys is empty, then the expiry of \a key
|
||||||
|
is changed. Otherwise, the expiry of \a subkeys is changed. If
|
||||||
|
\a expiry is not valid, then \a key or \a subkeys are set to never expire.
|
||||||
|
*/
|
||||||
|
virtual GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry,
|
||||||
|
const std::vector<GpgME::Subkey> &subkeys);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
|
void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
|
||||||
};
|
};
|
||||||
|
@ -54,20 +54,33 @@ QGpgMEChangeExpiryJob::QGpgMEChangeExpiryJob(Context *context)
|
|||||||
|
|
||||||
QGpgMEChangeExpiryJob::~QGpgMEChangeExpiryJob() {}
|
QGpgMEChangeExpiryJob::~QGpgMEChangeExpiryJob() {}
|
||||||
|
|
||||||
static QGpgMEChangeExpiryJob::result_type change_expiry(Context *ctx, const Key &key, const QDateTime &expiry)
|
static QGpgMEChangeExpiryJob::result_type change_expiry(Context *ctx, const Key &key, const QDateTime &expiry,
|
||||||
|
const std::vector<Subkey> &subkeys)
|
||||||
{
|
{
|
||||||
// convert expiry to "seconds from now"; use 1 second from now if expiry is before the current datetime
|
// convert expiry to "seconds from now"; use 1 second from now if expiry is before the current datetime
|
||||||
const unsigned long expires = expiry.isValid()
|
const unsigned long expires = expiry.isValid()
|
||||||
? std::max<qint64>(QDateTime::currentDateTime().secsTo(expiry), 1)
|
? std::max<qint64>(QDateTime::currentDateTime().secsTo(expiry), 1)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
auto err = ctx->setExpire(key, expires);
|
auto err = ctx->setExpire(key, expires, subkeys);
|
||||||
return std::make_tuple(err, QString(), Error());
|
return std::make_tuple(err, QString(), Error());
|
||||||
}
|
}
|
||||||
|
|
||||||
Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry)
|
Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry)
|
||||||
{
|
{
|
||||||
run(std::bind(&change_expiry, std::placeholders::_1, key, expiry));
|
return start(key, expiry, std::vector<Subkey>());
|
||||||
|
}
|
||||||
|
|
||||||
|
Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry, const std::vector<Subkey> &subkeys)
|
||||||
|
{
|
||||||
|
run(std::bind(&change_expiry, std::placeholders::_1, key, expiry, subkeys));
|
||||||
return Error();
|
return Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For ABI compat not pure virtual. */
|
||||||
|
Error ChangeExpiryJob::start(const Key &, const QDateTime &, const std::vector<Subkey> &)
|
||||||
|
{
|
||||||
|
return Error();
|
||||||
|
}
|
||||||
|
|
||||||
#include "qgpgmechangeexpiryjob.moc"
|
#include "qgpgmechangeexpiryjob.moc"
|
||||||
|
@ -60,6 +60,11 @@ public:
|
|||||||
|
|
||||||
/* from ChangeExpiryJob */
|
/* from ChangeExpiryJob */
|
||||||
GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) Q_DECL_OVERRIDE;
|
GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
/* from ChangeExpiryJob */
|
||||||
|
GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry,
|
||||||
|
const std::vector<GpgME::Subkey> &subkeys) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user