cpp: Get rid of AssuanResult due to its deprecation.
authorWerner Koch <wk@gnupg.org>
Tue, 23 Aug 2016 17:50:01 +0000 (19:50 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Wed, 24 Aug 2016 12:15:58 +0000 (14:15 +0200)
* lang/cpp/src/assuanresult.cpp: Remove.
* lang/cpp/src/assuanresult.h: Remove.
* lang/cpp/src/Makefile.am: Remove these files.
* lang/cpp/src/context.cpp: Remove header assuanresult.h
(assuanTransact): Change return type to Error.  Use
gpgme_op_assuan_transact_ext.
(startAssuanTransaction): Change return type to Error.
(assuanResult): Remove
* lang/cpp/src/context.h (assuanResult): Adjust for changes.

Signed-off-by: Werner Koch <wk@gnupg.org>
lang/cpp/src/Makefile.am
lang/cpp/src/assuanresult.cpp [deleted file]
lang/cpp/src/assuanresult.h [deleted file]
lang/cpp/src/context.cpp
lang/cpp/src/context.h
lang/cpp/src/vfsmountresult.h

index 188585a..e65a875 100644 (file)
@@ -25,7 +25,7 @@ lib_LTLIBRARIES = libgpgmepp.la
 
 main_sources = \
     exception.cpp context.cpp key.cpp trustitem.cpp data.cpp callbacks.cpp \
-    eventloopinteractor.cpp editinteractor.cpp assuanresult.cpp \
+    eventloopinteractor.cpp editinteractor.cpp \
     keylistresult.cpp keygenerationresult.cpp importresult.cpp \
     decryptionresult.cpp verificationresult.cpp \
     signingresult.cpp encryptionresult.cpp \
@@ -36,7 +36,7 @@ main_sources = \
     vfsmountresult.cpp configuration.cpp tofuinfo.cpp
 
 gpgmepp_headers = \
-    assuanresult.h configuration.h context.h data.h decryptionresult.h \
+    configuration.h context.h data.h decryptionresult.h \
     defaultassuantransaction.h editinteractor.h encryptionresult.h \
     engineinfo.h error.h eventloopinteractor.h exception.h global.h \
     gpgadduserideditinteractor.h gpgagentgetinfoassuantransaction.h \
diff --git a/lang/cpp/src/assuanresult.cpp b/lang/cpp/src/assuanresult.cpp
deleted file mode 100644 (file)
index 3d6d0a3..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-  assuanresult.cpp - wraps a gpgme assuan result
-  Copyright (C) 2009 Klarälvdalens Datakonsult AB
-
-  This file is part of GPGME++.
-
-  GPGME++ is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Library General Public
-  License as published by the Free Software Foundation; either
-  version 2 of the License, or (at your option) any later version.
-
-  GPGME++ is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU Library General Public License for more details.
-
-  You should have received a copy of the GNU Library General Public License
-  along with GPGME++; see the file COPYING.LIB.  If not, write to the
-  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-*/
-
-#include <assuanresult.h>
-#include "result_p.h"
-
-#include <gpgme.h>
-
-#include <istream>
-
-using namespace GpgME;
-
-class AssuanResult::Private
-{
-public:
-    explicit Private(const gpgme_assuan_result_t r)
-    {
-        if (!r) {
-            return;
-        }
-        error = r->err;
-    }
-
-    gpgme_error_t error;
-};
-
-AssuanResult::AssuanResult(gpgme_ctx_t ctx, int error)
-    : Result(error), d()
-{
-    init(ctx);
-}
-
-AssuanResult::AssuanResult(gpgme_ctx_t ctx, const Error &error)
-    : Result(error), d()
-{
-    init(ctx);
-}
-
-void AssuanResult::init(gpgme_ctx_t ctx)
-{
-    (void)ctx;
-    if (!ctx) {
-        return;
-    }
-    gpgme_assuan_result_t res = gpgme_op_assuan_result(ctx);
-    if (!res) {
-        return;
-    }
-    d.reset(new Private(res));
-}
-
-make_standard_stuff(AssuanResult)
-
-Error AssuanResult::assuanError() const
-{
-    if (d) {
-        return Error(d->error);
-    }
-    return Error();
-}
-
-std::ostream &GpgME::operator<<(std::ostream &os, const AssuanResult &result)
-{
-    os << "GpgME::AssuanResult(";
-    if (!result.isNull()) {
-        os << "\n error:       " << result.error()
-           << "\n assuanError: " << result.assuanError()
-           << "\n";
-    }
-    return os << ')';
-}
diff --git a/lang/cpp/src/assuanresult.h b/lang/cpp/src/assuanresult.h
deleted file mode 100644 (file)
index e59b5ac..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-  assuanresult.h - wraps a gpgme assuan result
-  Copyright (C) 2009 Klarälvdalens Datakonsult AB <info@kdab.com>
-  Author: Marc Mutz <marc@kdab.com>
-
-  This file is part of GPGME++.
-
-  GPGME++ is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Library General Public
-  License as published by the Free Software Foundation; either
-  version 2 of the License, or (at your option) any later version.
-
-  GPGME++ is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU Library General Public License for more details.
-
-  You should have received a copy of the GNU Library General Public License
-  along with GPGME++; see the file COPYING.LIB.  If not, write to the
-  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-*/
-
-#ifndef __GPGMEPP_ASSUANRESULT_H__
-#define __GPGMEPP_ASSUANRESULT_H__
-
-#include "gpgmefw.h"
-#include "result.h"
-#include "gpgmepp_export.h"
-
-#include <time.h>
-
-#include <vector>
-#include <iosfwd>
-#include <memory>
-
-namespace GpgME
-{
-
-class Error;
-
-class GPGMEPP_EXPORT AssuanResult : public Result
-{
-public:
-    AssuanResult();
-    AssuanResult(gpgme_ctx_t ctx, int error);
-    AssuanResult(gpgme_ctx_t ctx, const Error &error);
-    explicit AssuanResult(const Error &err);
-
-    const AssuanResult &operator=(AssuanResult other)
-    {
-        swap(other);
-        return *this;
-    }
-
-    void swap(AssuanResult &other)
-    {
-        Result::swap(other);
-        using std::swap;
-        swap(this->d, other.d);
-    }
-
-    bool isNull() const;
-
-    Error assuanError() const;
-
-    class Private;
-private:
-    void init(gpgme_ctx_t ctx);
-    std::shared_ptr<Private> d;
-};
-
-GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const AssuanResult &result);
-
-}
-
-GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(AssuanResult)
-
-#endif // __GPGMEPP_ASSUANRESULT_H__
index 11080cf..4e66d3b 100644 (file)
@@ -23,7 +23,6 @@
 #include <context.h>
 #include <eventloopinteractor.h>
 #include <trustitem.h>
-#include <assuanresult.h>
 #include <keylistresult.h>
 #include <keygenerationresult.h>
 #include <importresult.h>
@@ -801,26 +800,36 @@ static gpgme_error_t assuan_transaction_status_callback(void *opaque, const char
     return t->status(status, a.c_str()).encodedError();
 }
 
-AssuanResult Context::assuanTransact(const char *command)
+Error Context::assuanTransact(const char *command)
 {
     return assuanTransact(command, std::unique_ptr<AssuanTransaction>(new DefaultAssuanTransaction));
 }
 
-AssuanResult Context::assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction)
+Error Context::assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction)
 {
+    gpgme_error_t err, operr;
+
     d->lastop = Private::AssuanTransact;
     d->lastAssuanTransaction = std::move(transaction);
     if (!d->lastAssuanTransaction.get()) {
-        return AssuanResult(Error(d->lasterr = make_error(GPG_ERR_INV_ARG)));
+        return Error(d->lasterr = make_error(GPG_ERR_INV_ARG));
     }
-    d->lasterr = gpgme_op_assuan_transact(d->ctx, command,
-                                          assuan_transaction_data_callback,
-                                          d->lastAssuanTransaction.get(),
-                                          assuan_transaction_inquire_callback,
-                                          d, // sic!
-                                          assuan_transaction_status_callback,
-                                          d->lastAssuanTransaction.get());
-    return AssuanResult(d->ctx, d->lasterr);
+    err = gpgme_op_assuan_transact_ext
+      (d->ctx,
+       command,
+       assuan_transaction_data_callback,
+       d->lastAssuanTransaction.get(),
+       assuan_transaction_inquire_callback,
+       d,
+       assuan_transaction_status_callback,
+       d->lastAssuanTransaction.get(),
+       &operr);
+
+    if (!err)
+      err = operr;
+    d->lasterr = err;
+
+    return Error(d->lasterr);
 }
 
 Error Context::startAssuanTransaction(const char *command)
@@ -830,27 +839,26 @@ Error Context::startAssuanTransaction(const char *command)
 
 Error Context::startAssuanTransaction(const char *command, std::unique_ptr<AssuanTransaction> transaction)
 {
+    gpgme_error_t err;
+
     d->lastop = Private::AssuanTransact;
     d->lastAssuanTransaction = std::move(transaction);
     if (!d->lastAssuanTransaction.get()) {
         return Error(d->lasterr = make_error(GPG_ERR_INV_ARG));
     }
-    return Error(d->lasterr = gpgme_op_assuan_transact_start(d->ctx, command,
-                              assuan_transaction_data_callback,
-                              d->lastAssuanTransaction.get(),
-                              assuan_transaction_inquire_callback,
-                              d, // sic!
-                              assuan_transaction_status_callback,
-                              d->lastAssuanTransaction.get()));
-}
+    err = gpgme_op_assuan_transact_start
+      (d->ctx,
+       command,
+       assuan_transaction_data_callback,
+       d->lastAssuanTransaction.get(),
+       assuan_transaction_inquire_callback,
+       d,
+       assuan_transaction_status_callback,
+       d->lastAssuanTransaction.get());
 
-AssuanResult Context::assuanResult() const
-{
-    if (d->lastop & Private::AssuanTransact) {
-        return AssuanResult(d->ctx, d->lasterr);
-    } else {
-        return AssuanResult();
-    }
+    d->lasterr = err;
+
+    return Error(d->lasterr);
 }
 
 AssuanTransaction *Context::lastAssuanTransaction() const
index 29eba91..6518d4c 100644 (file)
@@ -46,7 +46,6 @@ class EventLoopInteractor;
 class EditInteractor;
 class AssuanTransaction;
 
-class AssuanResult;
 class KeyListResult;
 class KeyGenerationResult;
 class ImportResult;
@@ -240,11 +239,10 @@ public:
     // Assuan Transactions
     //
 
-    AssuanResult assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction);
-    AssuanResult assuanTransact(const char *command);
+    GpgME::Error assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction);
+    GpgME::Error assuanTransact(const char *command);
     GpgME::Error startAssuanTransaction(const char *command, std::unique_ptr<AssuanTransaction> transaction);
     GpgME::Error startAssuanTransaction(const char *command);
-    AssuanResult assuanResult() const;
 
     AssuanTransaction *lastAssuanTransaction() const;
     std::unique_ptr<AssuanTransaction> takeLastAssuanTransaction();
index abdd655..b46eeb1 100644 (file)
@@ -73,4 +73,4 @@ GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const VfsMountResult &
 
 GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(VfsMountResult)
 
-#endif // __GPGMEPP_ASSUANRESULT_H__
+#endif // __GPGMEPP_VFSMOUNTRESULT_H__