diff options
Diffstat (limited to '')
| -rw-r--r-- | lang/cpp/src/Makefile.am | 4 | ||||
| -rw-r--r-- | lang/cpp/src/assuanresult.cpp | 90 | ||||
| -rw-r--r-- | lang/cpp/src/assuanresult.h | 79 | ||||
| -rw-r--r-- | lang/cpp/src/context.cpp | 62 | ||||
| -rw-r--r-- | lang/cpp/src/context.h | 6 | ||||
| -rw-r--r-- | lang/cpp/src/vfsmountresult.h | 2 | 
6 files changed, 40 insertions, 203 deletions
| diff --git a/lang/cpp/src/Makefile.am b/lang/cpp/src/Makefile.am index 188585a7..e65a8752 100644 --- a/lang/cpp/src/Makefile.am +++ b/lang/cpp/src/Makefile.am @@ -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 index 3d6d0a3a..00000000 --- a/lang/cpp/src/assuanresult.cpp +++ /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 index e59b5ac2..00000000 --- a/lang/cpp/src/assuanresult.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -  assuanresult.h - wraps a gpgme assuan result -  Copyright (C) 2009 Klarälvdalens Datakonsult AB <[email protected]> -  Author: Marc Mutz <[email protected]> - -  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__ diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index 11080cfa..4e66d3b9 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -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 diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h index 29eba91b..6518d4cf 100644 --- a/lang/cpp/src/context.h +++ b/lang/cpp/src/context.h @@ -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(); diff --git a/lang/cpp/src/vfsmountresult.h b/lang/cpp/src/vfsmountresult.h index abdd655d..b46eeb1c 100644 --- a/lang/cpp/src/vfsmountresult.h +++ b/lang/cpp/src/vfsmountresult.h @@ -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__ | 
