Remove feature check ifdefs

* lang/cpp/src/assuanresult.cpp,
 lang/cpp/src/callbacks.cpp,
 lang/cpp/src/configuration.cpp,
 lang/cpp/src/context.cpp,
 lang/cpp/src/context_glib.cpp,
 lang/cpp/src/context_qt.cpp,
 lang/cpp/src/context_vanilla.cpp,
 lang/cpp/src/data.cpp,
 lang/cpp/src/decryptionresult.cpp,
 lang/cpp/src/defaultassuantransaction.cpp,
 lang/cpp/src/editinteractor.cpp,
 lang/cpp/src/encryptionresult.cpp,
 lang/cpp/src/engineinfo.cpp,
 lang/cpp/src/eventloopinteractor.cpp,
 lang/cpp/src/global.h,
 lang/cpp/src/gpgagentgetinfoassuantransaction.cpp,
 lang/cpp/src/importresult.cpp,
 lang/cpp/src/interfaces/assuantransaction.h,
 lang/cpp/src/key.cpp,
 lang/cpp/src/keygenerationresult.cpp,
 lang/cpp/src/keylistresult.cpp,
 lang/cpp/src/scdgetinfoassuantransaction.cpp,
 lang/cpp/src/signingresult.cpp,
 lang/cpp/src/trustitem.cpp,
 lang/cpp/src/util.h,
 lang/cpp/src/verificationresult.cpp,
 lang/cpp/src/vfsmountresult.cpp: Remove feature checks.
This commit is contained in:
Andre Heinecke 2016-02-22 19:07:41 +01:00
parent 0855a1296a
commit 433bb8e84b
27 changed files with 12 additions and 692 deletions

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <assuanresult.h> #include <assuanresult.h>
#include "result_p.h" #include "result_p.h"
@ -31,7 +29,6 @@
using namespace GpgME; using namespace GpgME;
#ifdef HAVE_GPGME_ASSUAN_ENGINE
class AssuanResult::Private class AssuanResult::Private
{ {
public: public:
@ -45,7 +42,6 @@ public:
gpgme_error_t error; gpgme_error_t error;
}; };
#endif
AssuanResult::AssuanResult(gpgme_ctx_t ctx, int error) AssuanResult::AssuanResult(gpgme_ctx_t ctx, int error)
: Result(error), d() : Result(error), d()
@ -62,7 +58,6 @@ AssuanResult::AssuanResult(gpgme_ctx_t ctx, const Error &error)
void AssuanResult::init(gpgme_ctx_t ctx) void AssuanResult::init(gpgme_ctx_t ctx)
{ {
(void)ctx; (void)ctx;
#ifdef HAVE_GPGME_ASSUAN_ENGINE
if (!ctx) { if (!ctx) {
return; return;
} }
@ -71,18 +66,15 @@ void AssuanResult::init(gpgme_ctx_t ctx)
return; return;
} }
d.reset(new Private(res)); d.reset(new Private(res));
#endif
} }
make_standard_stuff(AssuanResult) make_standard_stuff(AssuanResult)
Error AssuanResult::assuanError() const Error AssuanResult::assuanError() const
{ {
#ifdef HAVE_GPGME_ASSUAN_ENGINE
if (d) { if (d) {
return Error(d->error); return Error(d->error);
} }
#endif
return Error(); return Error();
} }

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "callbacks.h" #include "callbacks.h"
#include "util.h" #include "util.h"
@ -39,21 +37,9 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef HAVE_GPGME_SSIZE_T
# define gpgme_ssize_t ssize_t
#endif
#ifndef HAVE_GPGME_OFF_T
# define gpgme_off_t off_t
#endif
static inline gpgme_error_t make_err_from_syserror() static inline gpgme_error_t make_err_from_syserror()
{ {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return gpgme_error_from_syserror(); return gpgme_error_from_syserror();
#else
return gpg_error_from_syserror();
#endif
} }
using GpgME::ProgressProvider; using GpgME::ProgressProvider;
@ -92,11 +78,7 @@ gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char
size_t passphrase_length = std::strlen(passphrase); size_t passphrase_length = std::strlen(passphrase);
size_t written = 0; size_t written = 0;
do { do {
#ifdef HAVE_GPGME_IO_READWRITE
ssize_t now_written = gpgme_io_write(fd, passphrase + written, passphrase_length - written); ssize_t now_written = gpgme_io_write(fd, passphrase + written, passphrase_length - written);
#else
ssize_t now_written = write(fd, passphrase + written, passphrase_length - written);
#endif
if (now_written < 0) { if (now_written < 0) {
err = make_err_from_syserror(); err = make_err_from_syserror();
break; break;
@ -110,11 +92,7 @@ gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char
wipememory(passphrase, std::strlen(passphrase)); wipememory(passphrase, std::strlen(passphrase));
} }
free(passphrase); free(passphrase);
#ifdef HAVE_GPGME_IO_READWRITE
gpgme_io_write(fd, "\n", 1); gpgme_io_write(fd, "\n", 1);
#else
write(fd, "\n", 1);
#endif
return err; return err;
} }
@ -123,11 +101,7 @@ data_read_callback(void *opaque, void *buf, size_t buflen)
{ {
DataProvider *provider = static_cast<DataProvider *>(opaque); DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) { if (!provider) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#else
gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#endif
return -1; return -1;
} }
return (gpgme_ssize_t)provider->read(buf, buflen); return (gpgme_ssize_t)provider->read(buf, buflen);
@ -138,11 +112,7 @@ data_write_callback(void *opaque, const void *buf, size_t buflen)
{ {
DataProvider *provider = static_cast<DataProvider *>(opaque); DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) { if (!provider) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#else
gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#endif
return -1; return -1;
} }
return (gpgme_ssize_t)provider->write(buf, buflen); return (gpgme_ssize_t)provider->write(buf, buflen);
@ -153,19 +123,11 @@ data_seek_callback(void *opaque, gpgme_off_t offset, int whence)
{ {
DataProvider *provider = static_cast<DataProvider *>(opaque); DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) { if (!provider) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#else
gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#endif
return -1; return -1;
} }
if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) { if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL)); gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#else
gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#endif
return -1; return -1;
} }
return provider->seek((off_t)offset, whence); return provider->seek((off_t)offset, whence);

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "configuration.h" #include "configuration.h"
#include "error.h" #include "error.h"
#include "util.h" #include "util.h"
@ -58,7 +56,6 @@ struct nodelete {
std::vector<Component> Component::load(Error &returnedError) std::vector<Component> Component::load(Error &returnedError)
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
// //
// 1. get a context: // 1. get a context:
// //
@ -101,16 +98,11 @@ std::vector<Component> Component::load(Error &returnedError)
} }
return result; return result;
#else
returnedError = Error(make_error(GPG_ERR_NOT_SUPPORTED));
return std::vector<Component>();
#endif
} }
Error Component::save() const Error Component::save() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG)); return Error(make_error(GPG_ERR_INV_ARG));
} }
@ -128,41 +120,25 @@ Error Component::save() const
// 2. save the config: // 2. save the config:
// //
return Error(gpgme_op_conf_save(ctx.get(), comp.get())); return Error(gpgme_op_conf_save(ctx.get(), comp.get()));
#else
return Error(make_error(GPG_ERR_NOT_SUPPORTED));
#endif
} }
const char *Component::name() const const char *Component::name() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return comp ? comp->name : 0 ; return comp ? comp->name : 0 ;
#else
return 0;
#endif
} }
const char *Component::description() const const char *Component::description() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return comp ? comp->description : 0 ; return comp ? comp->description : 0 ;
#else
return 0;
#endif
} }
const char *Component::programName() const const char *Component::programName() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return comp ? comp->program_name : 0 ; return comp ? comp->program_name : 0 ;
#else
return 0;
#endif
} }
Option Component::option(unsigned int idx) const Option Component::option(unsigned int idx) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
gpgme_conf_opt_t opt = 0; gpgme_conf_opt_t opt = 0;
if (comp) { if (comp) {
opt = comp->options; opt = comp->options;
@ -173,17 +149,12 @@ Option Component::option(unsigned int idx) const
} }
if (opt) { if (opt) {
return Option(comp, opt); return Option(comp, opt);
} else {
#endif
return Option();
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
} }
#endif return Option();
} }
Option Component::option(const char *name) const Option Component::option(const char *name) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
gpgme_conf_opt_t opt = 0; gpgme_conf_opt_t opt = 0;
if (comp) { if (comp) {
opt = comp->options; opt = comp->options;
@ -194,37 +165,28 @@ Option Component::option(const char *name) const
} }
if (opt) { if (opt) {
return Option(comp, opt); return Option(comp, opt);
} else {
#endif
return Option();
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
} }
#endif return Option();
} }
unsigned int Component::numOptions() const unsigned int Component::numOptions() const
{ {
unsigned int result = 0; unsigned int result = 0;
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
for (gpgme_conf_opt_t opt = comp ? comp->options : 0 ; opt ; opt = opt->next) { for (gpgme_conf_opt_t opt = comp ? comp->options : 0 ; opt ; opt = opt->next) {
++result; ++result;
} }
#endif
return result; return result;
} }
std::vector<Option> Component::options() const std::vector<Option> Component::options() const
{ {
std::vector<Option> result; std::vector<Option> result;
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
for (gpgme_conf_opt_t opt = comp ? comp->options : 0 ; opt ; opt = opt->next) { for (gpgme_conf_opt_t opt = comp ? comp->options : 0 ; opt ; opt = opt->next) {
result.push_back(Option(comp, opt)); result.push_back(Option(comp, opt));
} }
#endif
return result; return result;
} }
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
static gpgme_conf_arg_t mygpgme_conf_arg_copy(gpgme_conf_arg_t other, gpgme_conf_type_t type) static gpgme_conf_arg_t mygpgme_conf_arg_copy(gpgme_conf_arg_t other, gpgme_conf_type_t type)
{ {
gpgme_conf_arg_t result = 0, last = 0; gpgme_conf_arg_t result = 0, last = 0;
@ -249,7 +211,6 @@ static gpgme_conf_arg_t mygpgme_conf_arg_copy(gpgme_conf_arg_t other, gpgme_conf
} }
return result; return result;
} }
#endif
Component Option::parent() const Component Option::parent() const
{ {
@ -258,65 +219,37 @@ Component Option::parent() const
unsigned int Option::flags() const unsigned int Option::flags() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? 0 : opt->flags; return isNull() ? 0 : opt->flags;
#else
return 0;
#endif
} }
Level Option::level() const Level Option::level() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? Internal : static_cast<Level>(opt->level) ; return isNull() ? Internal : static_cast<Level>(opt->level) ;
#else
return Internal;
#endif
} }
const char *Option::name() const const char *Option::name() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? 0 : opt->name ; return isNull() ? 0 : opt->name ;
#else
return 0;
#endif
} }
const char *Option::description() const const char *Option::description() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? 0 : opt->description ; return isNull() ? 0 : opt->description ;
#else
return 0;
#endif
} }
const char *Option::argumentName() const const char *Option::argumentName() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? 0 : opt->argname ; return isNull() ? 0 : opt->argname ;
#else
return 0;
#endif
} }
Type Option::type() const Type Option::type() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? NoType : static_cast<Type>(opt->type) ; return isNull() ? NoType : static_cast<Type>(opt->type) ;
#else
return NoType;
#endif
} }
Type Option::alternateType() const Type Option::alternateType() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? NoType : static_cast<Type>(opt->alt_type) ; return isNull() ? NoType : static_cast<Type>(opt->alt_type) ;
#else
return NoType;
#endif
} }
#if 0 #if 0
@ -473,64 +406,43 @@ optional<Option::Variant> Option::defaultValue() const
Argument Option::defaultValue() const Argument Option::defaultValue() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, opt->default_value, false); return Argument(comp.lock(), opt, opt->default_value, false);
} }
#else
return Argument();
#endif
} }
const char *Option::defaultDescription() const const char *Option::defaultDescription() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? 0 : opt->default_description ; return isNull() ? 0 : opt->default_description ;
#else
return 0;
#endif
} }
Argument Option::noArgumentValue() const Argument Option::noArgumentValue() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, opt->no_arg_value, false); return Argument(comp.lock(), opt, opt->no_arg_value, false);
} }
#else
return Argument();
#endif
} }
const char *Option::noArgumentDescription() const const char *Option::noArgumentDescription() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return isNull() ? 0 : opt->no_arg_description ; return isNull() ? 0 : opt->no_arg_description ;
#else
return 0;
#endif
} }
Argument Option::activeValue() const Argument Option::activeValue() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, opt->value, false); return Argument(comp.lock(), opt, opt->value, false);
} }
#else
return Argument();
#endif
} }
Argument Option::currentValue() const Argument Option::currentValue() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Argument(); return Argument();
} }
@ -539,27 +451,19 @@ Argument Option::currentValue() const
opt->value ? opt->value : opt->value ? opt->value :
/* else */ opt->default_value ; /* else */ opt->default_value ;
return Argument(comp.lock(), opt, arg, false); return Argument(comp.lock(), opt, arg, false);
#else
return Argument();
#endif
} }
Argument Option::newValue() const Argument Option::newValue() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, opt->new_value, false); return Argument(comp.lock(), opt, opt->new_value, false);
} }
#else
return Argument();
#endif
} }
bool Option::set() const bool Option::set() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return false; return false;
} else if (opt->change_value) { } else if (opt->change_value) {
@ -567,23 +471,15 @@ bool Option::set() const
} else { } else {
return opt->value; return opt->value;
} }
#else
return false;
#endif
} }
bool Option::dirty() const bool Option::dirty() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return !isNull() && opt->change_value ; return !isNull() && opt->change_value ;
#else
return false;
#endif
} }
Error Option::setNewValue(const Argument &argument) Error Option::setNewValue(const Argument &argument)
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG)); return Error(make_error(GPG_ERR_INV_ARG));
} else if (argument.isNull()) { } else if (argument.isNull()) {
@ -593,126 +489,84 @@ Error Option::setNewValue(const Argument &argument)
} else { } else {
return Error(make_error(GPG_ERR_ENOMEM)); return Error(make_error(GPG_ERR_ENOMEM));
} }
#else
return Error(make_error(GPG_ERR_NOT_SUPPORTED));
#endif
} }
Error Option::resetToActiveValue() Error Option::resetToActiveValue()
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG)); return Error(make_error(GPG_ERR_INV_ARG));
} else { } else {
return Error(gpgme_conf_opt_change(opt, 1, 0)); return Error(gpgme_conf_opt_change(opt, 1, 0));
} }
#else
return Error(make_error(GPG_ERR_NOT_SUPPORTED));
#endif
} }
Error Option::resetToDefaultValue() Error Option::resetToDefaultValue()
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull()) { if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG)); return Error(make_error(GPG_ERR_INV_ARG));
} else { } else {
return Error(gpgme_conf_opt_change(opt, 0, 0)); return Error(gpgme_conf_opt_change(opt, 0, 0));
} }
#else
return Error(make_error(GPG_ERR_NOT_SUPPORTED));
#endif
} }
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
static gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const void *value) static gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const void *value)
{ {
gpgme_conf_arg_t arg = 0; gpgme_conf_arg_t arg = 0;
#ifdef HAVE_GPGME_CONF_ARG_NEW_WITH_CONST_VALUE
if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, value)) { if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, value)) {
return 0; return 0;
} } else {
#else
if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, const_cast<void *>(value))) {
return 0;
}
#endif
else {
return arg; return arg;
} }
} }
#endif
Argument Option::createNoneArgument(bool set) const Argument Option::createNoneArgument(bool set) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || alternateType() != NoType) { if (isNull() || alternateType() != NoType) {
return Argument(); return Argument();
} else { } else {
if (set) { if (set) {
return createNoneListArgument(1); return createNoneListArgument(1);
} else {
#endif
return Argument();
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
} }
} }
#endif return Argument();
} }
Argument Option::createStringArgument(const char *value) const Argument Option::createStringArgument(const char *value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || alternateType() != StringType) { if (isNull() || alternateType() != StringType) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
} }
#else
return Argument();
#endif
} }
Argument Option::createStringArgument(const std::string &value) const Argument Option::createStringArgument(const std::string &value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || alternateType() != StringType) { if (isNull() || alternateType() != StringType) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value.c_str()), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value.c_str()), true);
} }
#else
return Argument();
#endif
} }
Argument Option::createIntArgument(int value) const Argument Option::createIntArgument(int value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || alternateType() != IntegerType) { if (isNull() || alternateType() != IntegerType) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, &value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, &value), true);
} }
#else
return Argument();
#endif
} }
Argument Option::createUIntArgument(unsigned int value) const Argument Option::createUIntArgument(unsigned int value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || alternateType() != UnsignedIntegerType) { if (isNull() || alternateType() != UnsignedIntegerType) {
return Argument(); return Argument();
} else { } else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, &value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, &value), true);
} }
#else
return Argument();
#endif
} }
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
namespace namespace
{ {
const void *to_void_star(const char *s) const void *to_void_star(const char *s)
@ -749,65 +603,39 @@ gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const std::vector<T> &val
return result; return result;
} }
} }
#endif
Argument Option::createNoneListArgument(unsigned int value) const Argument Option::createNoneListArgument(unsigned int value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (value) { if (value) {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_NONE, &value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_NONE, &value), true);
} else {
#endif
return Argument();
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
} }
#endif return Argument();
} }
Argument Option::createStringListArgument(const std::vector<const char *> &value) const Argument Option::createStringListArgument(const std::vector<const char *> &value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
#else
return Argument();
#endif
} }
Argument Option::createStringListArgument(const std::vector<std::string> &value) const Argument Option::createStringListArgument(const std::vector<std::string> &value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
#else
return Argument();
#endif
} }
Argument Option::createIntListArgument(const std::vector<int> &value) const Argument Option::createIntListArgument(const std::vector<int> &value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, value), true);
#else
return Argument();
#endif
} }
Argument Option::createUIntListArgument(const std::vector<unsigned int> &value) const Argument Option::createUIntListArgument(const std::vector<unsigned int> &value) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, value), true); return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, value), true);
#else
return Argument();
#endif
} }
Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg, bool owns) Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg, bool owns)
: comp(comp), : comp(comp),
opt(opt), opt(opt),
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
arg(owns ? arg : mygpgme_conf_arg_copy(arg, opt ? opt->alt_type : GPGME_CONF_NONE)) arg(owns ? arg : mygpgme_conf_arg_copy(arg, opt ? opt->alt_type : GPGME_CONF_NONE))
#else
arg(0)
#endif
{ {
} }
@ -825,20 +653,14 @@ Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, g
Argument::Argument(const Argument &other) Argument::Argument(const Argument &other)
: comp(other.comp), : comp(other.comp),
opt(other.opt), opt(other.opt),
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
arg(mygpgme_conf_arg_copy(other.arg, opt ? opt->alt_type : GPGME_CONF_NONE)) arg(mygpgme_conf_arg_copy(other.arg, opt ? opt->alt_type : GPGME_CONF_NONE))
#else
arg(0)
#endif
{ {
} }
Argument::~Argument() Argument::~Argument()
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
gpgme_conf_arg_release(arg, opt ? opt->alt_type : GPGME_CONF_NONE); gpgme_conf_arg_release(arg, opt ? opt->alt_type : GPGME_CONF_NONE);
#endif
} }
Option Argument::parent() const Option Argument::parent() const
@ -857,17 +679,14 @@ unsigned int Argument::numElements() const
return 0; return 0;
} }
unsigned int result = 0; unsigned int result = 0;
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) { for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
++result; ++result;
} }
#endif
return result; return result;
} }
const char *Argument::stringValue(unsigned int idx) const const char *Argument::stringValue(unsigned int idx) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || opt->alt_type != GPGME_CONF_STRING) { if (isNull() || opt->alt_type != GPGME_CONF_STRING) {
return 0; return 0;
} }
@ -877,14 +696,10 @@ const char *Argument::stringValue(unsigned int idx) const
--idx; --idx;
} }
return a ? a->value.string : 0 ; return a ? a->value.string : 0 ;
#else
return 0;
#endif
} }
int Argument::intValue(unsigned int idx) const int Argument::intValue(unsigned int idx) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || opt->alt_type != GPGME_CONF_INT32) { if (isNull() || opt->alt_type != GPGME_CONF_INT32) {
return 0; return 0;
} }
@ -894,14 +709,10 @@ int Argument::intValue(unsigned int idx) const
--idx; --idx;
} }
return a ? a->value.int32 : 0 ; return a ? a->value.int32 : 0 ;
#else
return 0;
#endif
} }
unsigned int Argument::uintValue(unsigned int idx) const unsigned int Argument::uintValue(unsigned int idx) const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || opt->alt_type != GPGME_CONF_UINT32) { if (isNull() || opt->alt_type != GPGME_CONF_UINT32) {
return 0; return 0;
} }
@ -911,21 +722,14 @@ unsigned int Argument::uintValue(unsigned int idx) const
--idx; --idx;
} }
return a ? a->value.uint32 : 0 ; return a ? a->value.uint32 : 0 ;
#else
return 0;
#endif
} }
unsigned int Argument::numberOfTimesSet() const unsigned int Argument::numberOfTimesSet() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || opt->alt_type != GPGME_CONF_NONE) { if (isNull() || opt->alt_type != GPGME_CONF_NONE) {
return 0; return 0;
} }
return arg->value.count; return arg->value.count;
#else
return 0;
#endif
} }
std::vector<const char *> Argument::stringValues() const std::vector<const char *> Argument::stringValues() const
@ -942,33 +746,25 @@ std::vector<const char *> Argument::stringValues() const
std::vector<int> Argument::intValues() const std::vector<int> Argument::intValues() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || opt->alt_type != GPGME_CONF_INT32) { if (isNull() || opt->alt_type != GPGME_CONF_INT32) {
return std::vector<int>(); return std::vector<int>();
} }
#endif
std::vector<int> result; std::vector<int> result;
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) { for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.int32); result.push_back(a->value.int32);
} }
#endif
return result; return result;
} }
std::vector<unsigned int> Argument::uintValues() const std::vector<unsigned int> Argument::uintValues() const
{ {
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
if (isNull() || opt->alt_type != GPGME_CONF_UINT32) { if (isNull() || opt->alt_type != GPGME_CONF_UINT32) {
return std::vector<unsigned int>(); return std::vector<unsigned int>();
} }
#endif
std::vector<unsigned int> result; std::vector<unsigned int> result;
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) { for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.uint32); result.push_back(a->value.uint32);
} }
#endif
return result; return result;
} }

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "config-gpgme++.h"
#include <context.h> #include <context.h>
#include <eventloopinteractor.h> #include <eventloopinteractor.h>
#include <trustitem.h> #include <trustitem.h>
@ -58,8 +56,6 @@ using std::endl;
#include <cassert> #include <cassert>
#include <qglobal.h>
namespace GpgME namespace GpgME
{ {
@ -77,7 +73,6 @@ static inline int xtoi_2(const char *str)
return xtoi_1(str) * 16U + xtoi_1(str + 1); return xtoi_1(str) * 16U + xtoi_1(str + 1);
} }
#ifdef HAVE_GPGME_ASSUAN_ENGINE
static void percent_unescape(std::string &s, bool plus2space) static void percent_unescape(std::string &s, bool plus2space)
{ {
std::string::iterator src = s.begin(), dest = s.begin(), end = s.end(); std::string::iterator src = s.begin(), dest = s.begin(), end = s.end();
@ -94,7 +89,6 @@ static void percent_unescape(std::string &s, bool plus2space)
} }
s.erase(dest, end); s.erase(dest, end);
} }
#endif
void initializeLibrary() void initializeLibrary()
{ {
@ -158,11 +152,7 @@ int Error::toErrno() const
// static // static
bool Error::hasSystemError() bool Error::hasSystemError()
{ {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return gpgme_err_code_from_syserror() == GPG_ERR_MISSING_ERRNO ; return gpgme_err_code_from_syserror() == GPG_ERR_MISSING_ERRNO ;
#else
return gpg_err_code_from_syserror() == GPG_ERR_MISSING_ERRNO ;
#endif
} }
// static // static
@ -174,41 +164,25 @@ void Error::setSystemError(gpg_err_code_t err)
// static // static
void Error::setErrno(int err) void Error::setErrno(int err)
{ {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(err); gpgme_err_set_errno(err);
#else
gpg_err_set_errno(err);
#endif
} }
// static // static
Error Error::fromSystemError(unsigned int src) Error Error::fromSystemError(unsigned int src)
{ {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return Error(gpgme_err_make(static_cast<gpgme_err_source_t>(src), gpgme_err_code_from_syserror())); return Error(gpgme_err_make(static_cast<gpgme_err_source_t>(src), gpgme_err_code_from_syserror()));
#else
return Error(gpg_err_make(static_cast<gpg_err_source_t>(src), gpg_err_code_from_syserror()));
#endif
} }
// static // static
Error Error::fromErrno(int err, unsigned int src) Error Error::fromErrno(int err, unsigned int src)
{ {
//#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return Error(gpgme_err_make(static_cast<gpgme_err_source_t>(src), gpgme_err_code_from_errno(err))); return Error(gpgme_err_make(static_cast<gpgme_err_source_t>(src), gpgme_err_code_from_errno(err)));
//#else
// return Error( gpg_err_make( static_cast<gpg_err_source_t>( src ), gpg_err_from_from_errno( err ) ) );
//#endif
} }
// static // static
Error Error::fromCode(unsigned int err, unsigned int src) Error Error::fromCode(unsigned int err, unsigned int src)
{ {
//#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return Error(gpgme_err_make(static_cast<gpgme_err_source_t>(src), static_cast<gpgme_err_code_t>(err))); return Error(gpgme_err_make(static_cast<gpgme_err_source_t>(src), static_cast<gpgme_err_code_t>(err)));
//#else
// return Error( gpg_err_make( static_cast<gpg_err_source_t>( src ), static_cast<gpgme_err_code_t>( err ) ) );
//#endif
} }
std::ostream &operator<<(std::ostream &os, const Error &err) std::ostream &operator<<(std::ostream &os, const Error &err)
@ -264,7 +238,6 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
switch (eng) { switch (eng) {
case AssuanEngine: case AssuanEngine:
#ifdef HAVE_GPGME_ASSUAN_ENGINE
if (const gpgme_error_t err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_ASSUAN)) { if (const gpgme_error_t err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_ASSUAN)) {
gpgme_release(ctx); gpgme_release(ctx);
if (error) { if (error) {
@ -273,14 +246,7 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
return std::auto_ptr<Context>(); return std::auto_ptr<Context>();
} }
break; break;
#else
if (error) {
*error = Error::fromCode(GPG_ERR_NOT_SUPPORTED);
}
return std::auto_ptr<Context>();
#endif
case G13Engine: case G13Engine:
#ifdef HAVE_GPGME_G13_VFS
if (const gpgme_error_t err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_G13)) { if (const gpgme_error_t err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_G13)) {
gpgme_release(ctx); gpgme_release(ctx);
if (error) { if (error) {
@ -289,12 +255,6 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
return std::auto_ptr<Context>(); return std::auto_ptr<Context>();
} }
break; break;
#else
if (error) {
*error = Error::fromCode(GPG_ERR_NOT_SUPPORTED);
}
return std::auto_ptr<Context>();
#endif
default: default:
if (error) { if (error) {
*error = Error::fromCode(GPG_ERR_INV_ARG); *error = Error::fromCode(GPG_ERR_INV_ARG);
@ -373,29 +333,17 @@ bool Context::textMode() const
void Context::setOffline(bool useOfflineMode) void Context::setOffline(bool useOfflineMode)
{ {
#ifdef HAVE_GPGME_CTX_OFFLINE
gpgme_set_offline(d->ctx, int(useOfflineMode)); gpgme_set_offline(d->ctx, int(useOfflineMode));
#else
Q_UNUSED(useOfflineMode);
#endif
} }
bool Context::offline() const bool Context::offline() const
{ {
#ifdef HAVE_GPGME_CTX_OFFLINE
return gpgme_get_offline(d->ctx); return gpgme_get_offline(d->ctx);
#else
return false;
#endif
} }
void Context::setIncludeCertificates(int which) void Context::setIncludeCertificates(int which)
{ {
if (which == DefaultCertificates) { if (which == DefaultCertificates) {
#ifdef HAVE_GPGME_INCLUDE_CERTS_DEFAULT
which = GPGME_INCLUDE_CERTS_DEFAULT; which = GPGME_INCLUDE_CERTS_DEFAULT;
#else
which = 1;
#endif
} }
gpgme_set_include_certs(d->ctx, which); gpgme_set_include_certs(d->ctx, which);
} }
@ -492,31 +440,19 @@ Error Context::setLocale(int cat, const char *val)
EngineInfo Context::engineInfo() const EngineInfo Context::engineInfo() const
{ {
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
return EngineInfo(gpgme_ctx_get_engine_info(d->ctx)); return EngineInfo(gpgme_ctx_get_engine_info(d->ctx));
#else
return EngineInfo();
#endif
} }
Error Context::setEngineFileName(const char *filename) Error Context::setEngineFileName(const char *filename)
{ {
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
const char *const home_dir = engineInfo().homeDirectory(); const char *const home_dir = engineInfo().homeDirectory();
return Error(gpgme_ctx_set_engine_info(d->ctx, gpgme_get_protocol(d->ctx), filename, home_dir)); return Error(gpgme_ctx_set_engine_info(d->ctx, gpgme_get_protocol(d->ctx), filename, home_dir));
#else
return Error::fromCode(GPG_ERR_NOT_IMPLEMENTED);
#endif
} }
Error Context::setEngineHomeDirectory(const char *home_dir) Error Context::setEngineHomeDirectory(const char *home_dir)
{ {
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
const char *const filename = engineInfo().fileName(); const char *const filename = engineInfo().fileName();
return Error(gpgme_ctx_set_engine_info(d->ctx, gpgme_get_protocol(d->ctx), filename, home_dir)); return Error(gpgme_ctx_set_engine_info(d->ctx, gpgme_get_protocol(d->ctx), filename, home_dir));
#else
return Error::fromCode(GPG_ERR_NOT_IMPLEMENTED);
#endif
} }
// //
@ -648,7 +584,6 @@ ImportResult Context::importKeys(const std::vector<Key> &kk)
d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED); d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED);
bool shouldHaveResult = false; bool shouldHaveResult = false;
#ifdef HAVE_GPGME_OP_IMPORT_KEYS
const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]); const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]);
gpgme_key_t *keys_it = &keys[0]; gpgme_key_t *keys_it = &keys[0];
for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) { for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) {
@ -659,7 +594,6 @@ ImportResult Context::importKeys(const std::vector<Key> &kk)
*keys_it++ = 0; *keys_it++ = 0;
d->lasterr = gpgme_op_import_keys(d->ctx, keys.get()); d->lasterr = gpgme_op_import_keys(d->ctx, keys.get());
shouldHaveResult = true; shouldHaveResult = true;
#endif
if ((gpgme_err_code(d->lasterr) == GPG_ERR_NOT_IMPLEMENTED || if ((gpgme_err_code(d->lasterr) == GPG_ERR_NOT_IMPLEMENTED ||
gpgme_err_code(d->lasterr) == GPG_ERR_NOT_SUPPORTED) && gpgme_err_code(d->lasterr) == GPG_ERR_NOT_SUPPORTED) &&
protocol() == CMS) { protocol() == CMS) {
@ -706,7 +640,6 @@ Error Context::startKeyImport(const Data &data)
Error Context::startKeyImport(const std::vector<Key> &kk) Error Context::startKeyImport(const std::vector<Key> &kk)
{ {
d->lastop = Private::Import; d->lastop = Private::Import;
#ifdef HAVE_GPGME_OP_IMPORT_KEYS
const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]); const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]);
gpgme_key_t *keys_it = &keys[0]; gpgme_key_t *keys_it = &keys[0];
for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) { for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) {
@ -716,10 +649,6 @@ Error Context::startKeyImport(const std::vector<Key> &kk)
} }
*keys_it++ = 0; *keys_it++ = 0;
return Error(d->lasterr = gpgme_op_import_keys_start(d->ctx, keys.get())); return Error(d->lasterr = gpgme_op_import_keys_start(d->ctx, keys.get()));
#else
(void)kk;
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
ImportResult Context::importResult() const ImportResult Context::importResult() const
@ -746,23 +675,13 @@ Error Context::startKeyDeletion(const Key &key, bool allowSecretKeyDeletion)
Error Context::passwd(const Key &key) Error Context::passwd(const Key &key)
{ {
d->lastop = Private::Passwd; d->lastop = Private::Passwd;
#ifdef HAVE_GPGME_OP_PASSWD
return Error(d->lasterr = gpgme_op_passwd(d->ctx, key.impl(), 0U)); return Error(d->lasterr = gpgme_op_passwd(d->ctx, key.impl(), 0U));
#else
(void)key;
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
Error Context::startPasswd(const Key &key) Error Context::startPasswd(const Key &key)
{ {
d->lastop = Private::Passwd; d->lastop = Private::Passwd;
#ifdef HAVE_GPGME_OP_PASSWD
return Error(d->lasterr = gpgme_op_passwd_start(d->ctx, key.impl(), 0U)); return Error(d->lasterr = gpgme_op_passwd_start(d->ctx, key.impl(), 0U));
#else
(void)key;
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
Error Context::edit(const Key &key, std::auto_ptr<EditInteractor> func, Data &data) Error Context::edit(const Key &key, std::auto_ptr<EditInteractor> func, Data &data)
@ -847,7 +766,6 @@ Error Context::endTrustItemListing()
return Error(d->lasterr = gpgme_op_trustlist_end(d->ctx)); return Error(d->lasterr = gpgme_op_trustlist_end(d->ctx));
} }
#ifdef HAVE_GPGME_ASSUAN_ENGINE
static gpgme_error_t assuan_transaction_data_callback(void *opaque, const void *data, size_t datalen) static gpgme_error_t assuan_transaction_data_callback(void *opaque, const void *data, size_t datalen)
{ {
assert(opaque); assert(opaque);
@ -881,7 +799,6 @@ static gpgme_error_t assuan_transaction_status_callback(void *opaque, const char
percent_unescape(a, true); // ### why doesn't gpgme do this?? percent_unescape(a, true); // ### why doesn't gpgme do this??
return t->status(status, a.c_str()).encodedError(); return t->status(status, a.c_str()).encodedError();
} }
#endif
AssuanResult Context::assuanTransact(const char *command) AssuanResult Context::assuanTransact(const char *command)
{ {
@ -895,7 +812,6 @@ AssuanResult Context::assuanTransact(const char *command, std::auto_ptr<AssuanTr
if (!d->lastAssuanTransaction.get()) { if (!d->lastAssuanTransaction.get()) {
return AssuanResult(Error(d->lasterr = make_error(GPG_ERR_INV_ARG))); return AssuanResult(Error(d->lasterr = make_error(GPG_ERR_INV_ARG)));
} }
#ifdef HAVE_GPGME_ASSUAN_ENGINE
d->lasterr = gpgme_op_assuan_transact(d->ctx, command, d->lasterr = gpgme_op_assuan_transact(d->ctx, command,
assuan_transaction_data_callback, assuan_transaction_data_callback,
d->lastAssuanTransaction.get(), d->lastAssuanTransaction.get(),
@ -903,10 +819,6 @@ AssuanResult Context::assuanTransact(const char *command, std::auto_ptr<AssuanTr
d, // sic! d, // sic!
assuan_transaction_status_callback, assuan_transaction_status_callback,
d->lastAssuanTransaction.get()); d->lastAssuanTransaction.get());
#else
(void)command;
d->lasterr = make_error(GPG_ERR_NOT_SUPPORTED);
#endif
return AssuanResult(d->ctx, d->lasterr); return AssuanResult(d->ctx, d->lasterr);
} }
@ -922,7 +834,6 @@ Error Context::startAssuanTransaction(const char *command, std::auto_ptr<AssuanT
if (!d->lastAssuanTransaction.get()) { if (!d->lastAssuanTransaction.get()) {
return Error(d->lasterr = make_error(GPG_ERR_INV_ARG)); return Error(d->lasterr = make_error(GPG_ERR_INV_ARG));
} }
#ifdef HAVE_GPGME_ASSUAN_ENGINE
return Error(d->lasterr = gpgme_op_assuan_transact_start(d->ctx, command, return Error(d->lasterr = gpgme_op_assuan_transact_start(d->ctx, command,
assuan_transaction_data_callback, assuan_transaction_data_callback,
d->lastAssuanTransaction.get(), d->lastAssuanTransaction.get(),
@ -930,10 +841,6 @@ Error Context::startAssuanTransaction(const char *command, std::auto_ptr<AssuanT
d, // sic! d, // sic!
assuan_transaction_status_callback, assuan_transaction_status_callback,
d->lastAssuanTransaction.get())); d->lastAssuanTransaction.get()));
#else
(void)command;
return Error(d->lasterr = make_error(GPG_ERR_NOT_SUPPORTED));
#endif
} }
AssuanResult Context::assuanResult() const AssuanResult Context::assuanResult() const
@ -1042,7 +949,6 @@ Error Context::startCombinedDecryptionAndVerification(const Data &cipherText, Da
return Error(d->lasterr = gpgme_op_decrypt_verify_start(d->ctx, cdp ? cdp->data : 0, pdp ? pdp->data : 0)); return Error(d->lasterr = gpgme_op_decrypt_verify_start(d->ctx, cdp ? cdp->data : 0, pdp ? pdp->data : 0));
} }
#ifdef HAVE_GPGME_OP_GETAUDITLOG
unsigned int to_auditlog_flags(unsigned int flags) unsigned int to_auditlog_flags(unsigned int flags)
{ {
unsigned int result = 0; unsigned int result = 0;
@ -1054,30 +960,19 @@ unsigned int to_auditlog_flags(unsigned int flags)
} }
return result; return result;
} }
#endif // HAVE_GPGME_OP_GETAUDITLOG
Error Context::startGetAuditLog(Data &output, unsigned int flags) Error Context::startGetAuditLog(Data &output, unsigned int flags)
{ {
d->lastop = Private::GetAuditLog; d->lastop = Private::GetAuditLog;
#ifdef HAVE_GPGME_OP_GETAUDITLOG
Data::Private *const odp = output.impl(); Data::Private *const odp = output.impl();
return Error(d->lasterr = gpgme_op_getauditlog_start(d->ctx, odp ? odp->data : 0, to_auditlog_flags(flags))); return Error(d->lasterr = gpgme_op_getauditlog_start(d->ctx, odp ? odp->data : 0, to_auditlog_flags(flags)));
#else
(void)output; (void)flags;
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
Error Context::getAuditLog(Data &output, unsigned int flags) Error Context::getAuditLog(Data &output, unsigned int flags)
{ {
d->lastop = Private::GetAuditLog; d->lastop = Private::GetAuditLog;
#ifdef HAVE_GPGME_OP_GETAUDITLOG
Data::Private *const odp = output.impl(); Data::Private *const odp = output.impl();
return Error(d->lasterr = gpgme_op_getauditlog(d->ctx, odp ? odp->data : 0, to_auditlog_flags(flags))); return Error(d->lasterr = gpgme_op_getauditlog(d->ctx, odp ? odp->data : 0, to_auditlog_flags(flags)));
#else
(void)output; (void)flags;
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
void Context::clearSigningKeys() void Context::clearSigningKeys()
@ -1108,46 +1003,30 @@ std::vector<Key> Context::signingKeys() const
void Context::clearSignatureNotations() void Context::clearSignatureNotations()
{ {
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
gpgme_sig_notation_clear(d->ctx); gpgme_sig_notation_clear(d->ctx);
#endif
} }
GpgME::Error Context::addSignatureNotation(const char *name, const char *value, unsigned int flags) GpgME::Error Context::addSignatureNotation(const char *name, const char *value, unsigned int flags)
{ {
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
return Error(gpgme_sig_notation_add(d->ctx, name, value, add_to_gpgme_sig_notation_flags_t(0, flags))); return Error(gpgme_sig_notation_add(d->ctx, name, value, add_to_gpgme_sig_notation_flags_t(0, flags)));
#else
(void)name; (void)value; (void)flags;
return Error(make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
GpgME::Error Context::addSignaturePolicyURL(const char *url, bool critical) GpgME::Error Context::addSignaturePolicyURL(const char *url, bool critical)
{ {
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
return Error(gpgme_sig_notation_add(d->ctx, 0, url, critical ? GPGME_SIG_NOTATION_CRITICAL : 0)); return Error(gpgme_sig_notation_add(d->ctx, 0, url, critical ? GPGME_SIG_NOTATION_CRITICAL : 0));
#else
(void)url; (void)critical;
return Error(make_error(GPG_ERR_NOT_IMPLEMENTED));
#endif
} }
const char *Context::signaturePolicyURL() const const char *Context::signaturePolicyURL() const
{ {
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) { for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) {
if (!n->name) { if (!n->name) {
return n->value; return n->value;
} }
} }
#endif
return 0;
} }
Notation Context::signatureNotation(unsigned int idx) const Notation Context::signatureNotation(unsigned int idx) const
{ {
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) { for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) {
if (n->name) { if (n->name) {
if (idx-- == 0) { if (idx-- == 0) {
@ -1155,20 +1034,17 @@ Notation Context::signatureNotation(unsigned int idx) const
} }
} }
} }
#endif
return Notation(); return Notation();
} }
std::vector<Notation> Context::signatureNotations() const std::vector<Notation> Context::signatureNotations() const
{ {
std::vector<Notation> result; std::vector<Notation> result;
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) { for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) {
if (n->name) { if (n->name) {
result.push_back(Notation(n)); result.push_back(Notation(n));
} }
} }
#endif
return result; return result;
} }
@ -1214,22 +1090,18 @@ static gpgme_encrypt_flags_t encryptflags2encryptflags(Context::EncryptionFlags
if (flags & Context::AlwaysTrust) { if (flags & Context::AlwaysTrust) {
result |= GPGME_ENCRYPT_ALWAYS_TRUST; result |= GPGME_ENCRYPT_ALWAYS_TRUST;
} }
#ifdef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
if (flags & Context::NoEncryptTo) { if (flags & Context::NoEncryptTo) {
result |= GPGME_ENCRYPT_NO_ENCRYPT_TO; result |= GPGME_ENCRYPT_NO_ENCRYPT_TO;
} }
#endif
return static_cast<gpgme_encrypt_flags_t>(result); return static_cast<gpgme_encrypt_flags_t>(result);
} }
EncryptionResult Context::encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags) EncryptionResult Context::encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags)
{ {
d->lastop = Private::Encrypt; d->lastop = Private::Encrypt;
#ifndef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
if (flags & NoEncryptTo) { if (flags & NoEncryptTo) {
return EncryptionResult(Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED))); return EncryptionResult(Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED)));
} }
#endif
const Data::Private *const pdp = plainText.impl(); const Data::Private *const pdp = plainText.impl();
Data::Private *const cdp = cipherText.impl(); Data::Private *const cdp = cipherText.impl();
gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ]; gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ];
@ -1258,11 +1130,9 @@ Error Context::encryptSymmetrically(const Data &plainText, Data &cipherText)
Error Context::startEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags) Error Context::startEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags)
{ {
d->lastop = Private::Encrypt; d->lastop = Private::Encrypt;
#ifndef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
if (flags & NoEncryptTo) { if (flags & NoEncryptTo) {
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED)); return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
} }
#endif
const Data::Private *const pdp = plainText.impl(); const Data::Private *const pdp = plainText.impl();
Data::Private *const cdp = cipherText.impl(); Data::Private *const cdp = cipherText.impl();
gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ]; gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ];
@ -1330,7 +1200,6 @@ Error Context::startCombinedSigningAndEncryption(const std::vector<Key> &recipie
Error Context::createVFS(const char *containerFile, const std::vector< Key > &recipients) Error Context::createVFS(const char *containerFile, const std::vector< Key > &recipients)
{ {
d->lastop = Private::CreateVFS; d->lastop = Private::CreateVFS;
#ifdef HAVE_GPGME_G13_VFS
gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ]; gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ];
gpgme_key_t *keys_it = keys; gpgme_key_t *keys_it = keys;
for (std::vector<Key>::const_iterator it = recipients.begin() ; it != recipients.end() ; ++it) { for (std::vector<Key>::const_iterator it = recipients.begin() ; it != recipients.end() ; ++it) {
@ -1348,34 +1217,19 @@ Error Context::createVFS(const char *containerFile, const std::vector< Key > &re
return error; return error;
} }
return Error(d->lasterr = op_err); return Error(d->lasterr = op_err);
#else
Q_UNUSED(containerFile);
Q_UNUSED(recipients);
return Error(d->lasterr = make_error(GPG_ERR_NOT_SUPPORTED));
#endif
} }
VfsMountResult Context::mountVFS(const char *containerFile, const char *mountDir) VfsMountResult Context::mountVFS(const char *containerFile, const char *mountDir)
{ {
d->lastop = Private::MountVFS; d->lastop = Private::MountVFS;
#ifdef HAVE_GPGME_G13_VFS
gpgme_error_t op_err; gpgme_error_t op_err;
d->lasterr = gpgme_op_vfs_mount(d->ctx, containerFile, mountDir, 0, &op_err); d->lasterr = gpgme_op_vfs_mount(d->ctx, containerFile, mountDir, 0, &op_err);
return VfsMountResult(d->ctx, Error(d->lasterr), Error(op_err)); return VfsMountResult(d->ctx, Error(d->lasterr), Error(op_err));
#else
Q_UNUSED(containerFile);
Q_UNUSED(mountDir);
return VfsMountResult(d->ctx, Error(d->lasterr = make_error(GPG_ERR_NOT_SUPPORTED)), Error());
#endif
} }
Error Context::cancelPendingOperation() Error Context::cancelPendingOperation()
{ {
#ifdef HAVE_GPGME_CANCEL_ASYNC
return Error(gpgme_cancel_async(d->ctx)); return Error(gpgme_cancel_async(d->ctx));
#else
return Error(gpgme_cancel(d->ctx));
#endif
} }
bool Context::poll() bool Context::poll()
@ -1553,23 +1407,11 @@ static gpgme_protocol_t engine2protocol(const GpgME::Engine engine)
case GpgME::GpgEngine: return GPGME_PROTOCOL_OpenPGP; case GpgME::GpgEngine: return GPGME_PROTOCOL_OpenPGP;
case GpgME::GpgSMEngine: return GPGME_PROTOCOL_CMS; case GpgME::GpgSMEngine: return GPGME_PROTOCOL_CMS;
case GpgME::GpgConfEngine: case GpgME::GpgConfEngine:
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return GPGME_PROTOCOL_GPGCONF; return GPGME_PROTOCOL_GPGCONF;
#else
break;
#endif
case GpgME::AssuanEngine: case GpgME::AssuanEngine:
#ifdef HAVE_GPGME_ASSUAN_ENGINE
return GPGME_PROTOCOL_ASSUAN; return GPGME_PROTOCOL_ASSUAN;
#else
break;
#endif
case GpgME::G13Engine: case GpgME::G13Engine:
#ifdef HAVE_GPGME_G13_VFS
return GPGME_PROTOCOL_G13; return GPGME_PROTOCOL_G13;
#else
break;
#endif
case GpgME::UnknownEngine: case GpgME::UnknownEngine:
; ;
} }
@ -1605,90 +1447,34 @@ static const unsigned long supported_features = 0
| GpgME::ValidatingKeylistModeFeature | GpgME::ValidatingKeylistModeFeature
| GpgME::CancelOperationFeature | GpgME::CancelOperationFeature
| GpgME::WrongKeyUsageFeature | GpgME::WrongKeyUsageFeature
#ifdef HAVE_GPGME_INCLUDE_CERTS_DEFAULT
| GpgME::DefaultCertificateInclusionFeature | GpgME::DefaultCertificateInclusionFeature
#endif
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
| GpgME::GetSetEngineInfoFeature | GpgME::GetSetEngineInfoFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
| GpgME::ClearAddGetSignatureNotationsFeature | GpgME::ClearAddGetSignatureNotationsFeature
#endif
#ifdef HAVE_GPGME_DATA_SET_FILE_NAME
| GpgME::SetDataFileNameFeeature | GpgME::SetDataFileNameFeeature
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
| GpgME::SignatureNotationsKeylistModeFeature | GpgME::SignatureNotationsKeylistModeFeature
#endif
#ifdef HAVE_GPGME_KEY_SIG_NOTATIONS
| GpgME::KeySignatureNotationsFeature | GpgME::KeySignatureNotationsFeature
#endif
#ifdef HAVE_GPGME_KEY_T_IS_QUALIFIED
| GpgME::KeyIsQualifiedFeature | GpgME::KeyIsQualifiedFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_CRITICAL
| GpgME::SignatureNotationsCriticalFlagFeature | GpgME::SignatureNotationsCriticalFlagFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
| GpgME::SignatureNotationsFlagsFeature | GpgME::SignatureNotationsFlagsFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_HUMAN_READABLE
| GpgME::SignatureNotationsHumanReadableFlagFeature | GpgME::SignatureNotationsHumanReadableFlagFeature
#endif
#ifdef HAVE_GPGME_SUBKEY_T_IS_QUALIFIED
| GpgME::SubkeyIsQualifiedFeature | GpgME::SubkeyIsQualifiedFeature
#endif
#ifdef HAVE_GPGME_ENGINE_INFO_T_HOME_DIR
| GpgME::EngineInfoHomeDirFeature | GpgME::EngineInfoHomeDirFeature
#endif
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_FILE_NAME
| GpgME::DecryptionResultFileNameFeature | GpgME::DecryptionResultFileNameFeature
#endif
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
| GpgME::DecryptionResultRecipientsFeature | GpgME::DecryptionResultRecipientsFeature
#endif
#ifdef HAVE_GPGME_VERIFY_RESULT_T_FILE_NAME
| GpgME::VerificationResultFileNameFeature | GpgME::VerificationResultFileNameFeature
#endif
#ifdef HAVE_GPGME_SIGNATURE_T_PKA_FIELDS
| GpgME::SignaturePkaFieldsFeature | GpgME::SignaturePkaFieldsFeature
#endif
#ifdef HAVE_GPGME_SIGNATURE_T_ALGORITHM_FIELDS
| GpgME::SignatureAlgorithmFieldsFeature | GpgME::SignatureAlgorithmFieldsFeature
#endif
#ifdef HAVE_GPGME_GET_FDPTR
| GpgME::FdPointerFeature | GpgME::FdPointerFeature
#endif
#ifdef HAVE_GPGME_OP_GETAUDITLOG
| GpgME::AuditLogFeature | GpgME::AuditLogFeature
#endif
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
| GpgME::GpgConfEngineFeature | GpgME::GpgConfEngineFeature
#endif
#ifdef HAVE_GPGME_CANCEL_ASYNC
| GpgME::CancelOperationAsyncFeature | GpgME::CancelOperationAsyncFeature
#endif
#ifdef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
| GpgME::NoEncryptToEncryptionFlagFeature | GpgME::NoEncryptToEncryptionFlagFeature
#endif
#ifdef HAVE_GPGME_SUBKEY_T_IS_CARDKEY
| GpgME::CardKeyFeature | GpgME::CardKeyFeature
#endif
#ifdef HAVE_GPGME_ASSUAN_ENGINE
| GpgME::AssuanEngineFeature | GpgME::AssuanEngineFeature
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
| GpgME::EphemeralKeylistModeFeature | GpgME::EphemeralKeylistModeFeature
#endif
#ifdef HAVE_GPGME_OP_IMPORT_KEYS
| GpgME::ImportFromKeyserverFeature | GpgME::ImportFromKeyserverFeature
#endif
#ifdef HAVE_GPGME_G13_VFS
| GpgME::G13VFSFeature | GpgME::G13VFSFeature
#endif
#ifdef HAVE_GPGME_OP_PASSWD
| GpgME::PasswdFeature | GpgME::PasswdFeature
#endif
; ;
static const unsigned long supported_features2 = 0 static const unsigned long supported_features2 = 0

View File

@ -20,22 +20,13 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <global.h> #include <global.h>
#ifdef HAVE_GPGME_GET_FDPTR
extern "C" GIOChannel *gpgme_get_fdptr(int); extern "C" GIOChannel *gpgme_get_fdptr(int);
#endif
GIOChannel *GpgME::getGIOChannel(int fd) GIOChannel *GpgME::getGIOChannel(int fd)
{ {
#ifdef HAVE_GPGME_GET_FDPTR
return gpgme_get_fdptr(fd); return gpgme_get_fdptr(fd);
#else
(void)fd;
return 0;
#endif
} }
QIODevice *GpgME::getQIODevice(int fd) QIODevice *GpgME::getQIODevice(int fd)

View File

@ -20,13 +20,9 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <global.h> #include <global.h>
#ifdef HAVE_GPGME_GET_FDPTR
extern "C" QIODevice *gpgme_get_fdptr(int); extern "C" QIODevice *gpgme_get_fdptr(int);
#endif
GIOChannel *GpgME::getGIOChannel(int) GIOChannel *GpgME::getGIOChannel(int)
{ {
@ -35,10 +31,5 @@ GIOChannel *GpgME::getGIOChannel(int)
QIODevice *GpgME::getQIODevice(int fd) QIODevice *GpgME::getQIODevice(int fd)
{ {
#ifdef HAVE_GPGME_GET_FDPTR
return gpgme_get_fdptr(fd); return gpgme_get_fdptr(fd);
#else
(void)fd;
return 0;
#endif
} }

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <global.h> #include <global.h>
GIOChannel *GpgME::getGIOChannel(int) GIOChannel *GpgME::getGIOChannel(int)

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "data_p.h" #include "data_p.h"
#include <error.h> #include <error.h>
#include <interfaces/dataprovider.h> #include <interfaces/dataprovider.h>
@ -166,21 +164,12 @@ GpgME::Error GpgME::Data::setEncoding(Encoding enc)
char *GpgME::Data::fileName() const char *GpgME::Data::fileName() const
{ {
#ifdef HAVE_GPGME_DATA_SET_FILE_NAME
return gpgme_data_get_file_name(d->data); return gpgme_data_get_file_name(d->data);
#else
return 0;
#endif
} }
GpgME::Error GpgME::Data::setFileName(const char *name) GpgME::Error GpgME::Data::setFileName(const char *name)
{ {
#ifdef HAVE_GPGME_DATA_SET_FILE_NAME
return Error(gpgme_data_set_file_name(d->data, name)); return Error(gpgme_data_set_file_name(d->data, name));
#else
(void)name;
return Error();
#endif
} }
ssize_t GpgME::Data::read(void *buffer, size_t length) ssize_t GpgME::Data::read(void *buffer, size_t length)

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <decryptionresult.h> #include <decryptionresult.h>
#include "result_p.h" #include "result_p.h"
#include "util.h" #include "util.h"
@ -44,19 +42,15 @@ public:
if (res.unsupported_algorithm) { if (res.unsupported_algorithm) {
res.unsupported_algorithm = strdup(res.unsupported_algorithm); res.unsupported_algorithm = strdup(res.unsupported_algorithm);
} }
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_FILE_NAME
if (res.file_name) { if (res.file_name) {
res.file_name = strdup(res.file_name); res.file_name = strdup(res.file_name);
} }
#endif
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
//FIXME: copying gpgme_recipient_t objects invalidates the keyid member, //FIXME: copying gpgme_recipient_t objects invalidates the keyid member,
//thus we use _keyid for now (internal API) //thus we use _keyid for now (internal API)
for (gpgme_recipient_t r = res.recipients ; r ; r = r->next) { for (gpgme_recipient_t r = res.recipients ; r ; r = r->next) {
recipients.push_back(*r); recipients.push_back(*r);
} }
res.recipients = 0; res.recipients = 0;
#endif
} }
~Private() ~Private()
{ {
@ -64,18 +58,14 @@ public:
std::free(res.unsupported_algorithm); std::free(res.unsupported_algorithm);
} }
res.unsupported_algorithm = 0; res.unsupported_algorithm = 0;
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_FILE_NAME
if (res.file_name) { if (res.file_name) {
std::free(res.file_name); std::free(res.file_name);
} }
res.file_name = 0; res.file_name = 0;
#endif
} }
_gpgme_op_decrypt_result res; _gpgme_op_decrypt_result res;
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
std::vector<_gpgme_recipient> recipients; std::vector<_gpgme_recipient> recipients;
#endif
}; };
GpgME::DecryptionResult::DecryptionResult(gpgme_ctx_t ctx, int error) GpgME::DecryptionResult::DecryptionResult(gpgme_ctx_t ctx, int error)
@ -116,29 +106,19 @@ bool GpgME::DecryptionResult::isWrongKeyUsage() const
const char *GpgME::DecryptionResult::fileName() const const char *GpgME::DecryptionResult::fileName() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_FILE_NAME
return d ? d->res.file_name : 0 ; return d ? d->res.file_name : 0 ;
#else
return 0;
#endif
} }
unsigned int GpgME::DecryptionResult::numRecipients() const unsigned int GpgME::DecryptionResult::numRecipients() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
return d ? d->recipients.size() : 0 ; return d ? d->recipients.size() : 0 ;
#else
return 0;
#endif
} }
GpgME::DecryptionResult::Recipient GpgME::DecryptionResult::recipient(unsigned int idx) const GpgME::DecryptionResult::Recipient GpgME::DecryptionResult::recipient(unsigned int idx) const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
if (d && idx < d->recipients.size()) { if (d && idx < d->recipients.size()) {
return Recipient(&d->recipients[idx]); return Recipient(&d->recipients[idx]);
} }
#endif
return Recipient(); return Recipient();
} }
@ -155,24 +135,20 @@ struct make_recipient {
std::vector<GpgME::DecryptionResult::Recipient> GpgME::DecryptionResult::recipients() const std::vector<GpgME::DecryptionResult::Recipient> GpgME::DecryptionResult::recipients() const
{ {
std::vector<Recipient> result; std::vector<Recipient> result;
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
if (d) { if (d) {
result.reserve(d->recipients.size()); result.reserve(d->recipients.size());
std::transform(d->recipients.begin(), d->recipients.end(), std::transform(d->recipients.begin(), d->recipients.end(),
std::back_inserter(result), std::back_inserter(result),
make_recipient()); make_recipient());
} }
#endif
return result; return result;
} }
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
class GpgME::DecryptionResult::Recipient::Private : public _gpgme_recipient class GpgME::DecryptionResult::Recipient::Private : public _gpgme_recipient
{ {
public: public:
Private(gpgme_recipient_t reci) : _gpgme_recipient(*reci) {} Private(gpgme_recipient_t reci) : _gpgme_recipient(*reci) {}
}; };
#endif
GpgME::DecryptionResult::Recipient::Recipient() GpgME::DecryptionResult::Recipient::Recipient()
: d() : d()
@ -183,11 +159,9 @@ GpgME::DecryptionResult::Recipient::Recipient()
GpgME::DecryptionResult::Recipient::Recipient(gpgme_recipient_t r) GpgME::DecryptionResult::Recipient::Recipient(gpgme_recipient_t r)
: d() : d()
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
if (r) { if (r) {
d.reset(new Private(r)); d.reset(new Private(r));
} }
#endif
} }
bool GpgME::DecryptionResult::Recipient::isNull() const bool GpgME::DecryptionResult::Recipient::isNull() const
@ -197,53 +171,43 @@ bool GpgME::DecryptionResult::Recipient::isNull() const
const char *GpgME::DecryptionResult::Recipient::keyID() const const char *GpgME::DecryptionResult::Recipient::keyID() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
//_keyid is internal API, but the public keyid is invalid after copying (see above) //_keyid is internal API, but the public keyid is invalid after copying (see above)
if (d) { if (d) {
return d->_keyid; return d->_keyid;
} }
#endif
return 0; return 0;
} }
const char *GpgME::DecryptionResult::Recipient::shortKeyID() const const char *GpgME::DecryptionResult::Recipient::shortKeyID() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
//_keyid is internal API, but the public keyid is invalid after copying (see above) //_keyid is internal API, but the public keyid is invalid after copying (see above)
if (d) { if (d) {
return d->_keyid + 8; return d->_keyid + 8;
} }
#endif
return 0; return 0;
} }
unsigned int GpgME::DecryptionResult::Recipient::publicKeyAlgorithm() const unsigned int GpgME::DecryptionResult::Recipient::publicKeyAlgorithm() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
if (d) { if (d) {
return d->pubkey_algo; return d->pubkey_algo;
} }
#endif
return 0; return 0;
} }
const char *GpgME::DecryptionResult::Recipient::publicKeyAlgorithmAsString() const const char *GpgME::DecryptionResult::Recipient::publicKeyAlgorithmAsString() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
if (d) { if (d) {
return gpgme_pubkey_algo_name(d->pubkey_algo); return gpgme_pubkey_algo_name(d->pubkey_algo);
} }
#endif
return 0; return 0;
} }
GpgME::Error GpgME::DecryptionResult::Recipient::status() const GpgME::Error GpgME::DecryptionResult::Recipient::status() const
{ {
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
if (d) { if (d) {
return Error(d->status); return Error(d->status);
} }
#endif
return Error(); return Error();
} }

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "defaultassuantransaction.h" #include "defaultassuantransaction.h"
#include "error.h" #include "error.h"
#include "data.h" #include "data.h"

View File

@ -20,17 +20,11 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "editinteractor.h" #include "editinteractor.h"
#include "callbacks.h" #include "callbacks.h"
#include "error.h" #include "error.h"
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
#include <gpgme.h> #include <gpgme.h>
#else
#include <gpg-error.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
# include <io.h> # include <io.h>
@ -42,6 +36,10 @@
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#ifndef GPG_ERR_ALREADY_SIGNED
# define GPG_ERR_ALREADY_SIGNED GPG_ERR_USER_1
#endif
using namespace GpgME; using namespace GpgME;
static const char *status_to_string(unsigned int status); static const char *status_to_string(unsigned int status);
@ -69,18 +67,7 @@ private:
{ {
size_t toWrite = count; size_t toWrite = count;
while (toWrite > 0) { while (toWrite > 0) {
#ifdef HAVE_GPGME_IO_READWRITE
const int n = gpgme_io_write(fd, buf, toWrite); const int n = gpgme_io_write(fd, buf, toWrite);
#else
# ifdef Q_OS_WIN
DWORD n;
if (!WriteFile((HANDLE)fd, buf, toWrite, &n, NULL)) {
return -1;
}
# else
const int n = write(fd, buf, toWrite);
# endif
#endif
if (n < 0) { if (n < 0) {
return n; return n;
} }
@ -124,11 +111,7 @@ public:
} }
// if there's a result, write it: // if there's a result, write it:
if (*result) { if (*result) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(0); gpgme_err_set_errno(0);
#else
gpg_err_set_errno(0);
#endif
const ssize_t len = std::strlen(result); const ssize_t len = std::strlen(result);
if (writeAll(fd, result, len) != len) { if (writeAll(fd, result, len) != len) {
err = Error::fromSystemError(); err = Error::fromSystemError();
@ -138,11 +121,7 @@ public:
goto error; goto error;
} }
} }
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(0); gpgme_err_set_errno(0);
#else
gpg_err_set_errno(0);
#endif
if (writeAll(fd, "\n", 1) != 1) { if (writeAll(fd, "\n", 1) != 1) {
err = Error::fromSystemError(); err = Error::fromSystemError();
if (ei->debug) { if (ei->debug) {

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <encryptionresult.h> #include <encryptionresult.h>
#include "result_p.h" #include "result_p.h"
#include "util.h" #include "util.h"

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "engineinfo.h" #include "engineinfo.h"
#include <gpgme.h> #include <gpgme.h>
@ -81,9 +79,5 @@ const char *GpgME::EngineInfo::requiredVersion() const
const char *GpgME::EngineInfo::homeDirectory() const const char *GpgME::EngineInfo::homeDirectory() const
{ {
#ifdef HAVE_GPGME_ENGINE_INFO_T_HOME_DIR
return isNull() ? 0 : d->info->home_dir; return isNull() ? 0 : d->info->home_dir;
#else
return 0;
#endif
} }

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <eventloopinteractor.h> #include <eventloopinteractor.h>
#include <context.h> #include <context.h>

View File

@ -28,7 +28,6 @@
#include "gpgmepp_export.h" #include "gpgmepp_export.h"
#include <iosfwd> #include <iosfwd>
#include <QByteArray>
namespace GpgME namespace GpgME
{ {

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "gpgagentgetinfoassuantransaction.h" #include "gpgagentgetinfoassuantransaction.h"
#include "error.h" #include "error.h"
#include "data.h" #include "data.h"

View File

@ -20,7 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <importresult.h> #include <importresult.h>
#include "result_p.h" #include "result_p.h"

View File

@ -26,6 +26,8 @@
#include "gpgmepp_export.h" #include "gpgmepp_export.h"
#include <stddef.h>
namespace GpgME namespace GpgME
{ {

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "config-gpgme++.h"
#include <key.h> #include <key.h>
#include "util.h" #include "util.h"
@ -224,11 +222,7 @@ bool Key::canAuthenticate() const
bool Key::isQualified() const bool Key::isQualified() const
{ {
#ifdef HAVE_GPGME_KEY_T_IS_QUALIFIED
return key && key->is_qualified; return key && key->is_qualified;
#else
return false;
#endif
} }
const char *Key::issuerSerial() const const char *Key::issuerSerial() const
@ -304,12 +298,9 @@ const Key &Key::mergeWith(const Key &other)
me->can_certify |= him->can_certify; me->can_certify |= him->can_certify;
me->secret |= him->secret; me->secret |= him->secret;
me->can_authenticate |= him->can_authenticate; me->can_authenticate |= him->can_authenticate;
#ifdef HAVE_GPGME_KEY_T_IS_QUALIFIED
me->is_qualified |= him->is_qualified; me->is_qualified |= him->is_qualified;
#endif
me->keylist_mode |= him->keylist_mode; me->keylist_mode |= him->keylist_mode;
#ifdef HAVE_GPGME_SUBKEY_T_IS_CARDKEY
// make sure the gpgme_sub_key_t::is_cardkey flag isn't lost: // make sure the gpgme_sub_key_t::is_cardkey flag isn't lost:
for (gpgme_sub_key_t mysk = me->subkeys ; mysk ; mysk = mysk->next) { for (gpgme_sub_key_t mysk = me->subkeys ; mysk ; mysk = mysk->next) {
for (gpgme_sub_key_t hissk = him->subkeys ; hissk ; hissk = hissk->next) { for (gpgme_sub_key_t hissk = him->subkeys ; hissk ; hissk = hissk->next) {
@ -319,7 +310,6 @@ const Key &Key::mergeWith(const Key &other)
} }
} }
} }
#endif
return *this; return *this;
} }
@ -415,29 +405,17 @@ bool Subkey::canAuthenticate() const
bool Subkey::isQualified() const bool Subkey::isQualified() const
{ {
#ifdef HAVE_GPGME_SUBKEY_T_IS_QUALIFIED
return subkey && subkey->is_qualified; return subkey && subkey->is_qualified;
#else
return false;
#endif
} }
bool Subkey::isCardKey() const bool Subkey::isCardKey() const
{ {
#ifdef HAVE_GPGME_SUBKEY_T_IS_CARDKEY
return subkey && subkey->is_cardkey; return subkey && subkey->is_cardkey;
#else
return false;
#endif
} }
const char *Subkey::cardSerialNumber() const const char *Subkey::cardSerialNumber() const
{ {
#ifdef HAVE_GPGME_SUBKEY_T_IS_CARDKEY
return subkey ? subkey->card_number : 0 ; return subkey ? subkey->card_number : 0 ;
#else
return 0;
#endif
} }
bool Subkey::isSecret() const bool Subkey::isSecret() const
@ -784,7 +762,6 @@ GpgME::Notation UserID::Signature::notation(unsigned int idx) const
if (!sig) { if (!sig) {
return GpgME::Notation(); return GpgME::Notation();
} }
#ifdef HAVE_GPGME_KEY_SIG_NOTATIONS
for (gpgme_sig_notation_t nota = sig->notations ; nota ; nota = nota->next) { for (gpgme_sig_notation_t nota = sig->notations ; nota ; nota = nota->next) {
if (nota->name) { if (nota->name) {
if (idx-- == 0) { if (idx-- == 0) {
@ -792,7 +769,6 @@ GpgME::Notation UserID::Signature::notation(unsigned int idx) const
} }
} }
} }
#endif
return GpgME::Notation(); return GpgME::Notation();
} }
@ -802,13 +778,11 @@ unsigned int UserID::Signature::numNotations() const
return 0; return 0;
} }
unsigned int count = 0; unsigned int count = 0;
#ifdef HAVE_GPGME_KEY_SIG_NOTATIONS
for (gpgme_sig_notation_t nota = sig->notations ; nota ; nota = nota->next) { for (gpgme_sig_notation_t nota = sig->notations ; nota ; nota = nota->next) {
if (nota->name) { if (nota->name) {
++count; // others are policy URLs... ++count; // others are policy URLs...
} }
} }
#endif
return count; return count;
} }
@ -818,20 +792,17 @@ std::vector<Notation> UserID::Signature::notations() const
return std::vector<GpgME::Notation>(); return std::vector<GpgME::Notation>();
} }
std::vector<GpgME::Notation> v; std::vector<GpgME::Notation> v;
#ifdef HAVE_GPGME_KEY_SIG_NOTATIONS
v.reserve(numNotations()); v.reserve(numNotations());
for (gpgme_sig_notation_t nota = sig->notations ; nota ; nota = nota->next) { for (gpgme_sig_notation_t nota = sig->notations ; nota ; nota = nota->next) {
if (nota->name) { if (nota->name) {
v.push_back(GpgME::Notation(nota)); v.push_back(GpgME::Notation(nota));
} }
} }
#endif
return v; return v;
} }
const char *UserID::Signature::policyURL() const const char *UserID::Signature::policyURL() const
{ {
#ifdef HAVE_GPGME_KEY_SIG_NOTATIONS
if (!sig) { if (!sig) {
return 0; return 0;
} }
@ -840,7 +811,6 @@ const char *UserID::Signature::policyURL() const
return nota->value; return nota->value;
} }
} }
#endif
return 0; return 0;
} }

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <keygenerationresult.h> #include <keygenerationresult.h>
#include "result_p.h" #include "result_p.h"

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <keylistresult.h> #include <keylistresult.h>
#include "result_p.h" #include "result_p.h"

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include "scdgetinfoassuantransaction.h" #include "scdgetinfoassuantransaction.h"
#include "error.h" #include "error.h"
#include "data.h" #include "data.h"

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <signingresult.h> #include <signingresult.h>
#include "result_p.h" #include "result_p.h"
#include "util.h" #include "util.h"

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <trustitem.h> #include <trustitem.h>
#include <gpgme.h> #include <gpgme.h>

View File

@ -68,18 +68,10 @@ static inline gpgme_keylist_mode_t add_to_gpgme_keylist_mode_t(unsigned int oldm
oldmode |= GPGME_KEYLIST_MODE_SIGS; oldmode |= GPGME_KEYLIST_MODE_SIGS;
} }
if (newmodes & GpgME::SignatureNotations) { if (newmodes & GpgME::SignatureNotations) {
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
oldmode |= GPGME_KEYLIST_MODE_SIG_NOTATIONS; oldmode |= GPGME_KEYLIST_MODE_SIG_NOTATIONS;
#elif !defined(NDEBUG)
;//std::cerr << "GpgME: ignoring SignatureNotations keylist flag (gpgme too old)." << std::endl;
#endif
} }
if (newmodes & GpgME::Ephemeral) { if (newmodes & GpgME::Ephemeral) {
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
oldmode |= GPGME_KEYLIST_MODE_EPHEMERAL; oldmode |= GPGME_KEYLIST_MODE_EPHEMERAL;
#elif !defined(NDEBUG)
;//std::cerr << "GpgME: ignoring Ephemeral keylist flag (gpgme too old)." << std::endl;
#endif
} }
if (newmodes & GpgME::Validate) { if (newmodes & GpgME::Validate) {
oldmode |= GPGME_KEYLIST_MODE_VALIDATE; oldmode |= GPGME_KEYLIST_MODE_VALIDATE;
@ -105,28 +97,20 @@ static inline unsigned int convert_from_gpgme_keylist_mode_t(unsigned int mode)
if (mode & GPGME_KEYLIST_MODE_SIGS) { if (mode & GPGME_KEYLIST_MODE_SIGS) {
result |= GpgME::Signatures; result |= GpgME::Signatures;
} }
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
if (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS) { if (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS) {
result |= GpgME::SignatureNotations; result |= GpgME::SignatureNotations;
} }
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
if (mode & GPGME_KEYLIST_MODE_EPHEMERAL) { if (mode & GPGME_KEYLIST_MODE_EPHEMERAL) {
result |= GpgME::Ephemeral; result |= GpgME::Ephemeral;
} }
#endif
if (mode & GPGME_KEYLIST_MODE_VALIDATE) { if (mode & GPGME_KEYLIST_MODE_VALIDATE) {
result |= GpgME::Validate; result |= GpgME::Validate;
} }
#ifndef NDEBUG #ifndef NDEBUG
if (mode & ~(GPGME_KEYLIST_MODE_LOCAL | if (mode & ~(GPGME_KEYLIST_MODE_LOCAL |
GPGME_KEYLIST_MODE_EXTERN | GPGME_KEYLIST_MODE_EXTERN |
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
GPGME_KEYLIST_MODE_SIG_NOTATIONS | GPGME_KEYLIST_MODE_SIG_NOTATIONS |
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
GPGME_KEYLIST_MODE_EPHEMERAL | GPGME_KEYLIST_MODE_EPHEMERAL |
#endif
GPGME_KEYLIST_MODE_VALIDATE | GPGME_KEYLIST_MODE_VALIDATE |
GPGME_KEYLIST_MODE_SIGS)) { GPGME_KEYLIST_MODE_SIGS)) {
//std::cerr << "GpgME: WARNING: gpgme_get_keylist_mode() returned an unknown flag!" << std::endl; //std::cerr << "GpgME: WARNING: gpgme_get_keylist_mode() returned an unknown flag!" << std::endl;
@ -137,43 +121,26 @@ static inline unsigned int convert_from_gpgme_keylist_mode_t(unsigned int mode)
static inline GpgME::Notation::Flags convert_from_gpgme_sig_notation_flags_t(unsigned int flags) static inline GpgME::Notation::Flags convert_from_gpgme_sig_notation_flags_t(unsigned int flags)
{ {
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
unsigned int result = 0; unsigned int result = 0;
#ifdef HAVE_GPGME_SIG_NOTATION_HUMAN_READABLE
if (flags & GPGME_SIG_NOTATION_HUMAN_READABLE) { if (flags & GPGME_SIG_NOTATION_HUMAN_READABLE) {
result |= GpgME::Notation::HumanReadable ; result |= GpgME::Notation::HumanReadable ;
} }
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_CRITICAL
if (flags & GPGME_SIG_NOTATION_CRITICAL) { if (flags & GPGME_SIG_NOTATION_CRITICAL) {
result |= GpgME::Notation::Critical ; result |= GpgME::Notation::Critical ;
} }
#endif
return static_cast<GpgME::Notation::Flags>(result); return static_cast<GpgME::Notation::Flags>(result);
#else
return GpgME::Notation::NoFlags;
#endif
} }
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
static inline gpgme_sig_notation_flags_t add_to_gpgme_sig_notation_flags_t(unsigned int oldflags, unsigned int newflags) static inline gpgme_sig_notation_flags_t add_to_gpgme_sig_notation_flags_t(unsigned int oldflags, unsigned int newflags)
{ {
unsigned int result = oldflags; unsigned int result = oldflags;
if (newflags & GpgME::Notation::HumanReadable) { if (newflags & GpgME::Notation::HumanReadable) {
#ifdef HAVE_GPGME_SIG_NOTATION_HUMAN_READABLE
result |= GPGME_SIG_NOTATION_HUMAN_READABLE; result |= GPGME_SIG_NOTATION_HUMAN_READABLE;
#elif !defined(NDEBUG)
//std::cerr << "GpgME::Context: ignoring HumanReadable signature notation flag (gpgme too old)" << std::endl;
#endif
} }
if (newflags & GpgME::Notation::Critical) { if (newflags & GpgME::Notation::Critical) {
#ifdef HAVE_GPGME_SIG_NOTATION_CRITICAL
result |= GPGME_SIG_NOTATION_CRITICAL; result |= GPGME_SIG_NOTATION_CRITICAL;
#elif !defined(NDEBUG)
//std::cerr << "GpgME::Context: ignoring Critical signature notation flag (gpgme too old)" << std::endl;
#endif
} }
return static_cast<gpgme_sig_notation_flags_t>(result); return static_cast<gpgme_sig_notation_flags_t>(result);
} }
#endif
#endif // __GPGMEPP_UTIL_H__ #endif // __GPGMEPP_UTIL_H__

View File

@ -20,7 +20,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <verificationresult.h> #include <verificationresult.h>
#include <notation.h> #include <notation.h>
#include "result_p.h" #include "result_p.h"
@ -45,11 +44,9 @@ public:
if (!r) { if (!r) {
return; return;
} }
#ifdef HAVE_GPGME_VERIFY_RESULT_T_FILE_NAME
if (r->file_name) { if (r->file_name) {
file_name = r->file_name; file_name = r->file_name;
} }
#endif
// copy recursively, using compiler-generated copy ctor. // copy recursively, using compiler-generated copy ctor.
// We just need to handle the pointers in the structs: // We just need to handle the pointers in the structs:
for (gpgme_signature_t is = r->signatures ; is ; is = is->next) { for (gpgme_signature_t is = r->signatures ; is ; is = is->next) {
@ -57,7 +54,6 @@ public:
if (is->fpr) { if (is->fpr) {
scopy->fpr = strdup(is->fpr); scopy->fpr = strdup(is->fpr);
} }
#ifdef HAVE_GPGME_SIGNATURE_T_PKA_FIELDS
// PENDING(marc) why does this crash on Windows in strdup()? // PENDING(marc) why does this crash on Windows in strdup()?
# ifndef _WIN32 # ifndef _WIN32
if (is->pka_address) { if (is->pka_address) {
@ -66,7 +62,6 @@ public:
# else # else
scopy->pka_address = 0; scopy->pka_address = 0;
# endif # endif
#endif
scopy->next = 0; scopy->next = 0;
sigs.push_back(scopy); sigs.push_back(scopy);
// copy notations: // copy notations:
@ -79,11 +74,7 @@ public:
} }
continue; continue;
} }
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
Nota n = { 0, 0, in->flags }; Nota n = { 0, 0, in->flags };
#else
Nota n = { 0, 0 };
#endif
n.name = strdup(in->name); n.name = strdup(in->name);
if (in->value) { if (in->value) {
n.value = strdup(in->value); n.value = strdup(in->value);
@ -96,9 +87,7 @@ public:
{ {
for (std::vector<gpgme_signature_t>::iterator it = sigs.begin() ; it != sigs.end() ; ++it) { for (std::vector<gpgme_signature_t>::iterator it = sigs.begin() ; it != sigs.end() ; ++it) {
std::free((*it)->fpr); std::free((*it)->fpr);
#ifdef HAVE_GPGME_SIGNATURE_T_PKA_FIELDS
std::free((*it)->pka_address); std::free((*it)->pka_address);
#endif
delete *it; *it = 0; delete *it; *it = 0;
} }
for (std::vector< std::vector<Nota> >::iterator it = nota.begin() ; it != nota.end() ; ++it) { for (std::vector< std::vector<Nota> >::iterator it = nota.begin() ; it != nota.end() ; ++it) {
@ -113,9 +102,7 @@ public:
struct Nota { struct Nota {
char *name; char *name;
char *value; char *value;
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
gpgme_sig_notation_flags_t flags; gpgme_sig_notation_flags_t flags;
#endif
}; };
std::vector<gpgme_signature_t> sigs; std::vector<gpgme_signature_t> sigs;
@ -265,30 +252,22 @@ bool GpgME::Signature::isWrongKeyUsage() const
bool GpgME::Signature::isVerifiedUsingChainModel() const bool GpgME::Signature::isVerifiedUsingChainModel() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_CHAIN_MODEL
return !isNull() && d->sigs[idx]->chain_model; return !isNull() && d->sigs[idx]->chain_model;
#else
return false;
#endif
} }
GpgME::Signature::PKAStatus GpgME::Signature::pkaStatus() const GpgME::Signature::PKAStatus GpgME::Signature::pkaStatus() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_PKA_FIELDS
if (!isNull()) { if (!isNull()) {
return static_cast<PKAStatus>(d->sigs[idx]->pka_trust); return static_cast<PKAStatus>(d->sigs[idx]->pka_trust);
} }
#endif
return UnknownPKAStatus; return UnknownPKAStatus;
} }
const char *GpgME::Signature::pkaAddress() const const char *GpgME::Signature::pkaAddress() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_PKA_FIELDS
if (!isNull()) { if (!isNull()) {
return d->sigs[idx]->pka_address; return d->sigs[idx]->pka_address;
} }
#endif
return 0; return 0;
} }
@ -331,41 +310,33 @@ GpgME::Error GpgME::Signature::nonValidityReason() const
unsigned int GpgME::Signature::publicKeyAlgorithm() const unsigned int GpgME::Signature::publicKeyAlgorithm() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_ALGORITHM_FIELDS
if (!isNull()) { if (!isNull()) {
return d->sigs[idx]->pubkey_algo; return d->sigs[idx]->pubkey_algo;
} }
#endif
return 0; return 0;
} }
const char *GpgME::Signature::publicKeyAlgorithmAsString() const const char *GpgME::Signature::publicKeyAlgorithmAsString() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_ALGORITHM_FIELDS
if (!isNull()) { if (!isNull()) {
return gpgme_pubkey_algo_name(d->sigs[idx]->pubkey_algo); return gpgme_pubkey_algo_name(d->sigs[idx]->pubkey_algo);
} }
#endif
return 0; return 0;
} }
unsigned int GpgME::Signature::hashAlgorithm() const unsigned int GpgME::Signature::hashAlgorithm() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_ALGORITHM_FIELDS
if (!isNull()) { if (!isNull()) {
return d->sigs[idx]->hash_algo; return d->sigs[idx]->hash_algo;
} }
#endif
return 0; return 0;
} }
const char *GpgME::Signature::hashAlgorithmAsString() const const char *GpgME::Signature::hashAlgorithmAsString() const
{ {
#ifdef HAVE_GPGME_SIGNATURE_T_ALGORITHM_FIELDS
if (!isNull()) { if (!isNull()) {
return gpgme_hash_algo_name(d->sigs[idx]->hash_algo); return gpgme_hash_algo_name(d->sigs[idx]->hash_algo);
} }
#endif
return 0; return 0;
} }
@ -478,13 +449,9 @@ GpgME::Notation::Flags GpgME::Notation::flags() const
{ {
return return
convert_from_gpgme_sig_notation_flags_t( convert_from_gpgme_sig_notation_flags_t(
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
isNull() ? 0 : isNull() ? 0 :
d->d ? d->d->nota[d->sidx][d->nidx].flags : d->d ? d->d->nota[d->sidx][d->nidx].flags :
d->nota ? d->nota->flags : 0); d->nota ? d->nota->flags : 0);
#else
0);
#endif
} }
bool GpgME::Notation::isHumanReadable() const bool GpgME::Notation::isHumanReadable() const

View File

@ -21,8 +21,6 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <config-gpgme++.h>
#include <vfsmountresult.h> #include <vfsmountresult.h>
#include "result_p.h" #include "result_p.h"
@ -33,7 +31,6 @@
using namespace GpgME; using namespace GpgME;
#ifdef HAVE_GPGME_G13_VFS
class VfsMountResult::Private class VfsMountResult::Private
{ {
public: public:
@ -51,7 +48,6 @@ public:
char *mountDir; char *mountDir;
}; };
#endif
VfsMountResult::VfsMountResult(gpgme_ctx_t ctx, const Error &error, const Error &opError) VfsMountResult::VfsMountResult(gpgme_ctx_t ctx, const Error &error, const Error &opError)
: Result(error ? error : opError), d() : Result(error ? error : opError), d()
@ -62,7 +58,6 @@ VfsMountResult::VfsMountResult(gpgme_ctx_t ctx, const Error &error, const Error
void VfsMountResult::init(gpgme_ctx_t ctx) void VfsMountResult::init(gpgme_ctx_t ctx)
{ {
(void)ctx; (void)ctx;
#ifdef HAVE_GPGME_G13_VFS
if (!ctx) { if (!ctx) {
return; return;
} }
@ -71,18 +66,15 @@ void VfsMountResult::init(gpgme_ctx_t ctx)
return; return;
} }
d.reset(new Private(res)); d.reset(new Private(res));
#endif
} }
make_standard_stuff(VfsMountResult) make_standard_stuff(VfsMountResult)
const char *VfsMountResult::mountDir() const const char *VfsMountResult::mountDir() const
{ {
#ifdef HAVE_GPGME_G13_VFS
if (d) { if (d) {
return d->mountDir; return d->mountDir;
} }
#endif
return 0; return 0;
} }