Qt / Cpp: Port auto_ptr to unique_ptr
* lang/cpp/src/context.cpp, lang/cpp/src/context.h, lang/cpp/src/context_p.h (Context::createForEngine), (Context::edit, Context::startEditing), (Context::takeLastEditInteractor, Context::cardEdit), (Context::startCardEditing, Context::takeLastCardEditInteractor), (Context::assuanTransact, Context::startAssuanTransaction), (Context::takeLastAssuanTransaction): Port to unique_ptr. * lang/qt/src/qgpgmeadduseridjob.cpp, lang/qt/src/qgpgmechangeexpiryjob.cpp, lang/qt/src/qgpgmechangeownertrustjob.cpp, lang/qt/src/qgpgmechangepasswdjob.cpp, lang/qt/src/qgpgmesignkeyjob.cpp: Update accordingly. -- This is another API break but as we already broke API with GpgME++ and QGpgME from KDE Frameworks this is a good time to do this to avoid using a deprected C++ class in the API.
This commit is contained in:
parent
9f14a24076
commit
9b36ebf37a
@ -224,14 +224,14 @@ Context *Context::createForProtocol(Protocol proto)
|
||||
return new Context(ctx);
|
||||
}
|
||||
|
||||
std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
|
||||
std::unique_ptr<Context> Context::createForEngine(Engine eng, Error *error)
|
||||
{
|
||||
gpgme_ctx_t ctx = 0;
|
||||
if (const gpgme_error_t err = gpgme_new(&ctx)) {
|
||||
if (error) {
|
||||
*error = Error(err);
|
||||
}
|
||||
return std::auto_ptr<Context>();
|
||||
return std::unique_ptr<Context>();
|
||||
}
|
||||
|
||||
switch (eng) {
|
||||
@ -241,7 +241,7 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
|
||||
if (error) {
|
||||
*error = Error(err);
|
||||
}
|
||||
return std::auto_ptr<Context>();
|
||||
return std::unique_ptr<Context>();
|
||||
}
|
||||
break;
|
||||
case G13Engine:
|
||||
@ -250,21 +250,21 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
|
||||
if (error) {
|
||||
*error = Error(err);
|
||||
}
|
||||
return std::auto_ptr<Context>();
|
||||
return std::unique_ptr<Context>();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (error) {
|
||||
*error = Error::fromCode(GPG_ERR_INV_ARG);
|
||||
}
|
||||
return std::auto_ptr<Context>();
|
||||
return std::unique_ptr<Context>();
|
||||
}
|
||||
|
||||
if (error) {
|
||||
*error = Error();
|
||||
}
|
||||
|
||||
return std::auto_ptr<Context>(new Context(ctx));
|
||||
return std::unique_ptr<Context>(new Context(ctx));
|
||||
}
|
||||
|
||||
//
|
||||
@ -685,10 +685,10 @@ Error Context::startPasswd(const Key &key)
|
||||
return Error(d->lasterr = gpgme_op_passwd_start(d->ctx, key.impl(), 0U));
|
||||
}
|
||||
|
||||
Error Context::edit(const Key &key, std::auto_ptr<EditInteractor> func, Data &data)
|
||||
Error Context::edit(const Key &key, std::unique_ptr<EditInteractor> func, Data &data)
|
||||
{
|
||||
d->lastop = Private::Edit;
|
||||
d->lastEditInteractor = func;
|
||||
d->lastEditInteractor = std::move(func);
|
||||
Data::Private *const dp = data.impl();
|
||||
return Error(d->lasterr = gpgme_op_edit(d->ctx, key.impl(),
|
||||
d->lastEditInteractor.get() ? edit_interactor_callback : 0,
|
||||
@ -696,10 +696,10 @@ Error Context::edit(const Key &key, std::auto_ptr<EditInteractor> func, Data &da
|
||||
dp ? dp->data : 0));
|
||||
}
|
||||
|
||||
Error Context::startEditing(const Key &key, std::auto_ptr<EditInteractor> func, Data &data)
|
||||
Error Context::startEditing(const Key &key, std::unique_ptr<EditInteractor> func, Data &data)
|
||||
{
|
||||
d->lastop = Private::Edit;
|
||||
d->lastEditInteractor = func;
|
||||
d->lastEditInteractor = std::move(func);
|
||||
Data::Private *const dp = data.impl();
|
||||
return Error(d->lasterr = gpgme_op_edit_start(d->ctx, key.impl(),
|
||||
d->lastEditInteractor.get() ? edit_interactor_callback : 0,
|
||||
@ -712,15 +712,15 @@ EditInteractor *Context::lastEditInteractor() const
|
||||
return d->lastEditInteractor.get();
|
||||
}
|
||||
|
||||
std::auto_ptr<EditInteractor> Context::takeLastEditInteractor()
|
||||
std::unique_ptr<EditInteractor> Context::takeLastEditInteractor()
|
||||
{
|
||||
return d->lastEditInteractor;
|
||||
return std::move(d->lastEditInteractor);
|
||||
}
|
||||
|
||||
Error Context::cardEdit(const Key &key, std::auto_ptr<EditInteractor> func, Data &data)
|
||||
Error Context::cardEdit(const Key &key, std::unique_ptr<EditInteractor> func, Data &data)
|
||||
{
|
||||
d->lastop = Private::CardEdit;
|
||||
d->lastCardEditInteractor = func;
|
||||
d->lastCardEditInteractor = std::move(func);
|
||||
Data::Private *const dp = data.impl();
|
||||
return Error(d->lasterr = gpgme_op_card_edit(d->ctx, key.impl(),
|
||||
d->lastCardEditInteractor.get() ? edit_interactor_callback : 0,
|
||||
@ -728,10 +728,10 @@ Error Context::cardEdit(const Key &key, std::auto_ptr<EditInteractor> func, Data
|
||||
dp ? dp->data : 0));
|
||||
}
|
||||
|
||||
Error Context::startCardEditing(const Key &key, std::auto_ptr<EditInteractor> func, Data &data)
|
||||
Error Context::startCardEditing(const Key &key, std::unique_ptr<EditInteractor> func, Data &data)
|
||||
{
|
||||
d->lastop = Private::CardEdit;
|
||||
d->lastCardEditInteractor = func;
|
||||
d->lastCardEditInteractor = std::move(func);
|
||||
Data::Private *const dp = data.impl();
|
||||
return Error(d->lasterr = gpgme_op_card_edit_start(d->ctx, key.impl(),
|
||||
d->lastCardEditInteractor.get() ? edit_interactor_callback : 0,
|
||||
@ -744,9 +744,9 @@ EditInteractor *Context::lastCardEditInteractor() const
|
||||
return d->lastCardEditInteractor.get();
|
||||
}
|
||||
|
||||
std::auto_ptr<EditInteractor> Context::takeLastCardEditInteractor()
|
||||
std::unique_ptr<EditInteractor> Context::takeLastCardEditInteractor()
|
||||
{
|
||||
return d->lastCardEditInteractor;
|
||||
return std::move(d->lastCardEditInteractor);
|
||||
}
|
||||
|
||||
Error Context::startTrustItemListing(const char *pattern, int maxLevel)
|
||||
@ -803,13 +803,13 @@ static gpgme_error_t assuan_transaction_status_callback(void *opaque, const char
|
||||
|
||||
AssuanResult Context::assuanTransact(const char *command)
|
||||
{
|
||||
return assuanTransact(command, std::auto_ptr<AssuanTransaction>(new DefaultAssuanTransaction));
|
||||
return assuanTransact(command, std::unique_ptr<AssuanTransaction>(new DefaultAssuanTransaction));
|
||||
}
|
||||
|
||||
AssuanResult Context::assuanTransact(const char *command, std::auto_ptr<AssuanTransaction> transaction)
|
||||
AssuanResult Context::assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction)
|
||||
{
|
||||
d->lastop = Private::AssuanTransact;
|
||||
d->lastAssuanTransaction = transaction;
|
||||
d->lastAssuanTransaction = std::move(transaction);
|
||||
if (!d->lastAssuanTransaction.get()) {
|
||||
return AssuanResult(Error(d->lasterr = make_error(GPG_ERR_INV_ARG)));
|
||||
}
|
||||
@ -825,13 +825,13 @@ AssuanResult Context::assuanTransact(const char *command, std::auto_ptr<AssuanTr
|
||||
|
||||
Error Context::startAssuanTransaction(const char *command)
|
||||
{
|
||||
return startAssuanTransaction(command, std::auto_ptr<AssuanTransaction>(new DefaultAssuanTransaction));
|
||||
return startAssuanTransaction(command, std::unique_ptr<AssuanTransaction>(new DefaultAssuanTransaction));
|
||||
}
|
||||
|
||||
Error Context::startAssuanTransaction(const char *command, std::auto_ptr<AssuanTransaction> transaction)
|
||||
Error Context::startAssuanTransaction(const char *command, std::unique_ptr<AssuanTransaction> transaction)
|
||||
{
|
||||
d->lastop = Private::AssuanTransact;
|
||||
d->lastAssuanTransaction = transaction;
|
||||
d->lastAssuanTransaction = std::move(transaction);
|
||||
if (!d->lastAssuanTransaction.get()) {
|
||||
return Error(d->lasterr = make_error(GPG_ERR_INV_ARG));
|
||||
}
|
||||
@ -858,9 +858,9 @@ AssuanTransaction *Context::lastAssuanTransaction() const
|
||||
return d->lastAssuanTransaction.get();
|
||||
}
|
||||
|
||||
std::auto_ptr<AssuanTransaction> Context::takeLastAssuanTransaction()
|
||||
std::unique_ptr<AssuanTransaction> Context::takeLastAssuanTransaction()
|
||||
{
|
||||
return d->lastAssuanTransaction;
|
||||
return std::move(d->lastAssuanTransaction);
|
||||
}
|
||||
|
||||
DecryptionResult Context::decrypt(const Data &cipherText, Data &plainText)
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
//
|
||||
|
||||
static Context *createForProtocol(Protocol proto);
|
||||
static std::auto_ptr<Context> createForEngine(Engine engine, Error *err = 0);
|
||||
static std::unique_ptr<Context> createForEngine(Engine engine, Error *err = 0);
|
||||
virtual ~Context();
|
||||
|
||||
//
|
||||
@ -188,21 +188,21 @@ public:
|
||||
// Key Editing
|
||||
//
|
||||
|
||||
GpgME::Error edit(const Key &key, std::auto_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error startEditing(const Key &key, std::auto_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error edit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error startEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
||||
|
||||
EditInteractor *lastEditInteractor() const;
|
||||
std::auto_ptr<EditInteractor> takeLastEditInteractor();
|
||||
std::unique_ptr<EditInteractor> takeLastEditInteractor();
|
||||
|
||||
//
|
||||
// SmartCard Editing
|
||||
//
|
||||
|
||||
GpgME::Error cardEdit(const Key &key, std::auto_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error startCardEditing(const Key &key, std::auto_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error cardEdit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
||||
GpgME::Error startCardEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
||||
|
||||
EditInteractor *lastCardEditInteractor() const;
|
||||
std::auto_ptr<EditInteractor> takeLastCardEditInteractor();
|
||||
std::unique_ptr<EditInteractor> takeLastCardEditInteractor();
|
||||
|
||||
//
|
||||
// Trust Item Management
|
||||
@ -216,14 +216,14 @@ public:
|
||||
// Assuan Transactions
|
||||
//
|
||||
|
||||
AssuanResult assuanTransact(const char *command, std::auto_ptr<AssuanTransaction> transaction);
|
||||
AssuanResult assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction);
|
||||
AssuanResult assuanTransact(const char *command);
|
||||
GpgME::Error startAssuanTransaction(const char *command, std::auto_ptr<AssuanTransaction> transaction);
|
||||
GpgME::Error startAssuanTransaction(const char *command, std::unique_ptr<AssuanTransaction> transaction);
|
||||
GpgME::Error startAssuanTransaction(const char *command);
|
||||
AssuanResult assuanResult() const;
|
||||
|
||||
AssuanTransaction *lastAssuanTransaction() const;
|
||||
std::auto_ptr<AssuanTransaction> takeLastAssuanTransaction();
|
||||
std::unique_ptr<AssuanTransaction> takeLastAssuanTransaction();
|
||||
|
||||
//
|
||||
//
|
||||
|
@ -75,8 +75,8 @@ public:
|
||||
Operation lastop;
|
||||
gpgme_error_t lasterr;
|
||||
Data lastAssuanInquireData;
|
||||
std::auto_ptr<AssuanTransaction> lastAssuanTransaction;
|
||||
std::auto_ptr<EditInteractor> lastEditInteractor, lastCardEditInteractor;
|
||||
std::unique_ptr<AssuanTransaction> lastAssuanTransaction;
|
||||
std::unique_ptr<EditInteractor> lastEditInteractor, lastCardEditInteractor;
|
||||
};
|
||||
|
||||
} // namespace GpgME
|
||||
|
@ -57,18 +57,16 @@ QGpgMEAddUserIDJob::~QGpgMEAddUserIDJob() {}
|
||||
static QGpgMEAddUserIDJob::result_type add_user_id(Context *ctx, const Key &key, const QString &name, const QString &email, const QString &comment)
|
||||
{
|
||||
|
||||
std::auto_ptr<GpgAddUserIDEditInteractor> gau(new GpgAddUserIDEditInteractor);
|
||||
GpgAddUserIDEditInteractor *gau = new GpgAddUserIDEditInteractor;
|
||||
|
||||
gau->setNameUtf8(name.toUtf8().constData());
|
||||
gau->setEmailUtf8(email.toUtf8().constData());
|
||||
gau->setCommentUtf8(comment.toUtf8().constData());
|
||||
|
||||
std::auto_ptr<EditInteractor> ei(gau);
|
||||
|
||||
QGpgME::QByteArrayDataProvider dp;
|
||||
Data data(&dp);
|
||||
assert(!data.isNull());
|
||||
const Error err = ctx->edit(key, ei, data);
|
||||
const Error err = ctx->edit(key, std::unique_ptr<EditInteractor> (gau), data);
|
||||
Error ae;
|
||||
const QString log = _detail::audit_log_as_html(ctx, ae);
|
||||
return std::make_tuple(err, log, ae);
|
||||
|
@ -59,15 +59,14 @@ QGpgMEChangeExpiryJob::~QGpgMEChangeExpiryJob() {}
|
||||
|
||||
static QGpgMEChangeExpiryJob::result_type change_expiry(Context *ctx, const Key &key, const QDateTime &expiry)
|
||||
{
|
||||
std::auto_ptr<EditInteractor>
|
||||
ei(expiry.isValid()
|
||||
EditInteractor *ei = expiry.isValid()
|
||||
? new GpgSetExpiryTimeEditInteractor(expiry.date().toString(Qt::ISODate).toStdString())
|
||||
: new GpgSetExpiryTimeEditInteractor());
|
||||
: new GpgSetExpiryTimeEditInteractor();
|
||||
|
||||
QGpgME::QByteArrayDataProvider dp;
|
||||
Data data(&dp);
|
||||
assert(!data.isNull());
|
||||
const Error err = ctx->edit(key, ei, data);
|
||||
const Error err = ctx->edit(key, std::unique_ptr<EditInteractor> (ei), data);
|
||||
Error ae;
|
||||
const QString log = _detail::audit_log_as_html(ctx, ae);
|
||||
return std::make_tuple(err, log, ae);
|
||||
|
@ -56,14 +56,13 @@ QGpgMEChangeOwnerTrustJob::~QGpgMEChangeOwnerTrustJob() {}
|
||||
|
||||
static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, const Key &key, Key::OwnerTrust trust)
|
||||
{
|
||||
std::auto_ptr<EditInteractor>
|
||||
ei(new GpgSetOwnerTrustEditInteractor(trust));
|
||||
EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(trust);
|
||||
|
||||
QGpgME::QByteArrayDataProvider dp;
|
||||
Data data(&dp);
|
||||
assert(!data.isNull());
|
||||
|
||||
const Error err = ctx->edit(key, ei, data);
|
||||
const Error err = ctx->edit(key, std::unique_ptr<EditInteractor>(ei), data);
|
||||
Error ae;
|
||||
const QString log = _detail::audit_log_as_html(ctx, ae);
|
||||
return std::make_tuple(err, log, ae);
|
||||
|
@ -56,7 +56,7 @@ QGpgMEChangePasswdJob::~QGpgMEChangePasswdJob() {}
|
||||
static QGpgMEChangePasswdJob::result_type change_passwd(Context *ctx, const Key &key)
|
||||
{
|
||||
#if 0 // in case we want to fall back to edit interactor for gpg...
|
||||
std::auto_ptr<EditInteractor> ei(new GpgChangePasswdEditInteractor);
|
||||
std::unique_ptr<EditInteractor> ei(new GpgChangePasswdEditInteractor);
|
||||
|
||||
QGpgME::QByteArrayDataProvider dp;
|
||||
Data data(&dp);
|
||||
|
@ -64,18 +64,16 @@ static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, cons
|
||||
QGpgME::QByteArrayDataProvider dp;
|
||||
Data data(&dp);
|
||||
|
||||
std::auto_ptr<GpgSignKeyEditInteractor> skei(new GpgSignKeyEditInteractor);
|
||||
GpgSignKeyEditInteractor *skei(new GpgSignKeyEditInteractor);
|
||||
skei->setUserIDsToSign(uids);
|
||||
skei->setCheckLevel(checkLevel);
|
||||
skei->setSigningOptions(opts);
|
||||
|
||||
std::auto_ptr<EditInteractor> ei(skei);
|
||||
|
||||
if (!signer.isNull())
|
||||
if (const Error err = ctx->addSigningKey(signer)) {
|
||||
return std::make_tuple(err, QString(), Error());
|
||||
}
|
||||
const Error err = ctx->edit(key, ei, data);
|
||||
const Error err = ctx->edit(key, std::unique_ptr<EditInteractor> (skei), data);
|
||||
Error ae;
|
||||
const QString log = _detail::audit_log_as_html(ctx, ae);
|
||||
return std::make_tuple(err, log, ae);
|
||||
|
Loading…
Reference in New Issue
Block a user