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

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA.
*/
#include <config-gpgme++.h>
#include "callbacks.h"
#include "util.h"
@ -39,21 +37,9 @@
#include <unistd.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()
{
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return gpgme_error_from_syserror();
#else
return gpg_error_from_syserror();
#endif
}
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 written = 0;
do {
#ifdef HAVE_GPGME_IO_READWRITE
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) {
err = make_err_from_syserror();
break;
@ -110,11 +92,7 @@ gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char
wipememory(passphrase, std::strlen(passphrase));
}
free(passphrase);
#ifdef HAVE_GPGME_IO_READWRITE
gpgme_io_write(fd, "\n", 1);
#else
write(fd, "\n", 1);
#endif
return err;
}
@ -123,11 +101,7 @@ data_read_callback(void *opaque, void *buf, size_t buflen)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
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 (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);
if (!provider) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
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 (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);
if (!provider) {
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
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;
}
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));
#else
gpg_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
#endif
return -1;
}
return provider->seek((off_t)offset, whence);

View File

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

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA.
*/
#include "config-gpgme++.h"
#include <context.h>
#include <eventloopinteractor.h>
#include <trustitem.h>
@ -58,8 +56,6 @@ using std::endl;
#include <cassert>
#include <qglobal.h>
namespace GpgME
{
@ -77,7 +73,6 @@ static inline int xtoi_2(const char *str)
return xtoi_1(str) * 16U + xtoi_1(str + 1);
}
#ifdef HAVE_GPGME_ASSUAN_ENGINE
static void percent_unescape(std::string &s, bool plus2space)
{
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);
}
#endif
void initializeLibrary()
{
@ -158,11 +152,7 @@ int Error::toErrno() const
// static
bool Error::hasSystemError()
{
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return gpgme_err_code_from_syserror() == GPG_ERR_MISSING_ERRNO ;
#else
return gpg_err_code_from_syserror() == GPG_ERR_MISSING_ERRNO ;
#endif
}
// static
@ -174,41 +164,25 @@ void Error::setSystemError(gpg_err_code_t err)
// static
void Error::setErrno(int err)
{
#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
gpgme_err_set_errno(err);
#else
gpg_err_set_errno(err);
#endif
}
// static
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()));
#else
return Error(gpg_err_make(static_cast<gpg_err_source_t>(src), gpg_err_code_from_syserror()));
#endif
}
// static
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)));
//#else
// return Error( gpg_err_make( static_cast<gpg_err_source_t>( src ), gpg_err_from_from_errno( err ) ) );
//#endif
}
// static
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)));
//#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)
@ -264,7 +238,6 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
switch (eng) {
case AssuanEngine:
#ifdef HAVE_GPGME_ASSUAN_ENGINE
if (const gpgme_error_t err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_ASSUAN)) {
gpgme_release(ctx);
if (error) {
@ -273,14 +246,7 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
return std::auto_ptr<Context>();
}
break;
#else
if (error) {
*error = Error::fromCode(GPG_ERR_NOT_SUPPORTED);
}
return std::auto_ptr<Context>();
#endif
case G13Engine:
#ifdef HAVE_GPGME_G13_VFS
if (const gpgme_error_t err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_G13)) {
gpgme_release(ctx);
if (error) {
@ -289,12 +255,6 @@ std::auto_ptr<Context> Context::createForEngine(Engine eng, Error *error)
return std::auto_ptr<Context>();
}
break;
#else
if (error) {
*error = Error::fromCode(GPG_ERR_NOT_SUPPORTED);
}
return std::auto_ptr<Context>();
#endif
default:
if (error) {
*error = Error::fromCode(GPG_ERR_INV_ARG);
@ -373,29 +333,17 @@ bool Context::textMode() const
void Context::setOffline(bool useOfflineMode)
{
#ifdef HAVE_GPGME_CTX_OFFLINE
gpgme_set_offline(d->ctx, int(useOfflineMode));
#else
Q_UNUSED(useOfflineMode);
#endif
}
bool Context::offline() const
{
#ifdef HAVE_GPGME_CTX_OFFLINE
return gpgme_get_offline(d->ctx);
#else
return false;
#endif
}
void Context::setIncludeCertificates(int which)
{
if (which == DefaultCertificates) {
#ifdef HAVE_GPGME_INCLUDE_CERTS_DEFAULT
which = GPGME_INCLUDE_CERTS_DEFAULT;
#else
which = 1;
#endif
}
gpgme_set_include_certs(d->ctx, which);
}
@ -492,31 +440,19 @@ Error Context::setLocale(int cat, const char *val)
EngineInfo Context::engineInfo() const
{
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
return EngineInfo(gpgme_ctx_get_engine_info(d->ctx));
#else
return EngineInfo();
#endif
}
Error Context::setEngineFileName(const char *filename)
{
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
const char *const home_dir = engineInfo().homeDirectory();
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)
{
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
const char *const filename = engineInfo().fileName();
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);
bool shouldHaveResult = false;
#ifdef HAVE_GPGME_OP_IMPORT_KEYS
const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]);
gpgme_key_t *keys_it = &keys[0];
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;
d->lasterr = gpgme_op_import_keys(d->ctx, keys.get());
shouldHaveResult = true;
#endif
if ((gpgme_err_code(d->lasterr) == GPG_ERR_NOT_IMPLEMENTED ||
gpgme_err_code(d->lasterr) == GPG_ERR_NOT_SUPPORTED) &&
protocol() == CMS) {
@ -706,7 +640,6 @@ Error Context::startKeyImport(const Data &data)
Error Context::startKeyImport(const std::vector<Key> &kk)
{
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 ]);
gpgme_key_t *keys_it = &keys[0];
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;
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
@ -746,23 +675,13 @@ Error Context::startKeyDeletion(const Key &key, bool allowSecretKeyDeletion)
Error Context::passwd(const Key &key)
{
d->lastop = Private::Passwd;
#ifdef HAVE_GPGME_OP_PASSWD
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)
{
d->lastop = Private::Passwd;
#ifdef HAVE_GPGME_OP_PASSWD
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)
@ -847,7 +766,6 @@ Error Context::endTrustItemListing()
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)
{
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??
return t->status(status, a.c_str()).encodedError();
}
#endif
AssuanResult Context::assuanTransact(const char *command)
{
@ -895,7 +812,6 @@ AssuanResult Context::assuanTransact(const char *command, std::auto_ptr<AssuanTr
if (!d->lastAssuanTransaction.get()) {
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,
assuan_transaction_data_callback,
d->lastAssuanTransaction.get(),
@ -903,10 +819,6 @@ AssuanResult Context::assuanTransact(const char *command, std::auto_ptr<AssuanTr
d, // sic!
assuan_transaction_status_callback,
d->lastAssuanTransaction.get());
#else
(void)command;
d->lasterr = make_error(GPG_ERR_NOT_SUPPORTED);
#endif
return AssuanResult(d->ctx, d->lasterr);
}
@ -922,7 +834,6 @@ Error Context::startAssuanTransaction(const char *command, std::auto_ptr<AssuanT
if (!d->lastAssuanTransaction.get()) {
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,
assuan_transaction_data_callback,
d->lastAssuanTransaction.get(),
@ -930,10 +841,6 @@ Error Context::startAssuanTransaction(const char *command, std::auto_ptr<AssuanT
d, // sic!
assuan_transaction_status_callback,
d->lastAssuanTransaction.get()));
#else
(void)command;
return Error(d->lasterr = make_error(GPG_ERR_NOT_SUPPORTED));
#endif
}
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));
}
#ifdef HAVE_GPGME_OP_GETAUDITLOG
unsigned int to_auditlog_flags(unsigned int flags)
{
unsigned int result = 0;
@ -1054,30 +960,19 @@ unsigned int to_auditlog_flags(unsigned int flags)
}
return result;
}
#endif // HAVE_GPGME_OP_GETAUDITLOG
Error Context::startGetAuditLog(Data &output, unsigned int flags)
{
d->lastop = Private::GetAuditLog;
#ifdef HAVE_GPGME_OP_GETAUDITLOG
Data::Private *const odp = output.impl();
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)
{
d->lastop = Private::GetAuditLog;
#ifdef HAVE_GPGME_OP_GETAUDITLOG
Data::Private *const odp = output.impl();
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()
@ -1108,46 +1003,30 @@ std::vector<Key> Context::signingKeys() const
void Context::clearSignatureNotations()
{
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
gpgme_sig_notation_clear(d->ctx);
#endif
}
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)));
#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)
{
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
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
{
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
for (gpgme_sig_notation_t n = gpgme_sig_notation_get(d->ctx) ; n ; n = n->next) {
if (!n->name) {
return n->value;
}
}
#endif
return 0;
}
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) {
if (n->name) {
if (idx-- == 0) {
@ -1155,20 +1034,17 @@ Notation Context::signatureNotation(unsigned int idx) const
}
}
}
#endif
return Notation();
}
std::vector<Notation> Context::signatureNotations() const
{
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) {
if (n->name) {
result.push_back(Notation(n));
}
}
#endif
return result;
}
@ -1214,22 +1090,18 @@ static gpgme_encrypt_flags_t encryptflags2encryptflags(Context::EncryptionFlags
if (flags & Context::AlwaysTrust) {
result |= GPGME_ENCRYPT_ALWAYS_TRUST;
}
#ifdef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
if (flags & Context::NoEncryptTo) {
result |= GPGME_ENCRYPT_NO_ENCRYPT_TO;
}
#endif
return static_cast<gpgme_encrypt_flags_t>(result);
}
EncryptionResult Context::encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags)
{
d->lastop = Private::Encrypt;
#ifndef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
if (flags & NoEncryptTo) {
return EncryptionResult(Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED)));
}
#endif
const Data::Private *const pdp = plainText.impl();
Data::Private *const cdp = cipherText.impl();
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)
{
d->lastop = Private::Encrypt;
#ifndef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
if (flags & NoEncryptTo) {
return Error(d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED));
}
#endif
const Data::Private *const pdp = plainText.impl();
Data::Private *const cdp = cipherText.impl();
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)
{
d->lastop = Private::CreateVFS;
#ifdef HAVE_GPGME_G13_VFS
gpgme_key_t *const keys = new gpgme_key_t[ recipients.size() + 1 ];
gpgme_key_t *keys_it = keys;
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(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)
{
d->lastop = Private::MountVFS;
#ifdef HAVE_GPGME_G13_VFS
gpgme_error_t 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));
#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()
{
#ifdef HAVE_GPGME_CANCEL_ASYNC
return Error(gpgme_cancel_async(d->ctx));
#else
return Error(gpgme_cancel(d->ctx));
#endif
}
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::GpgSMEngine: return GPGME_PROTOCOL_CMS;
case GpgME::GpgConfEngine:
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
return GPGME_PROTOCOL_GPGCONF;
#else
break;
#endif
case GpgME::AssuanEngine:
#ifdef HAVE_GPGME_ASSUAN_ENGINE
return GPGME_PROTOCOL_ASSUAN;
#else
break;
#endif
case GpgME::G13Engine:
#ifdef HAVE_GPGME_G13_VFS
return GPGME_PROTOCOL_G13;
#else
break;
#endif
case GpgME::UnknownEngine:
;
}
@ -1605,90 +1447,34 @@ static const unsigned long supported_features = 0
| GpgME::ValidatingKeylistModeFeature
| GpgME::CancelOperationFeature
| GpgME::WrongKeyUsageFeature
#ifdef HAVE_GPGME_INCLUDE_CERTS_DEFAULT
| GpgME::DefaultCertificateInclusionFeature
#endif
#ifdef HAVE_GPGME_CTX_GETSET_ENGINE_INFO
| GpgME::GetSetEngineInfoFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_CLEARADDGET
| GpgME::ClearAddGetSignatureNotationsFeature
#endif
#ifdef HAVE_GPGME_DATA_SET_FILE_NAME
| GpgME::SetDataFileNameFeeature
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
| GpgME::SignatureNotationsKeylistModeFeature
#endif
#ifdef HAVE_GPGME_KEY_SIG_NOTATIONS
| GpgME::KeySignatureNotationsFeature
#endif
#ifdef HAVE_GPGME_KEY_T_IS_QUALIFIED
| GpgME::KeyIsQualifiedFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_CRITICAL
| GpgME::SignatureNotationsCriticalFlagFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
| GpgME::SignatureNotationsFlagsFeature
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_HUMAN_READABLE
| GpgME::SignatureNotationsHumanReadableFlagFeature
#endif
#ifdef HAVE_GPGME_SUBKEY_T_IS_QUALIFIED
| GpgME::SubkeyIsQualifiedFeature
#endif
#ifdef HAVE_GPGME_ENGINE_INFO_T_HOME_DIR
| GpgME::EngineInfoHomeDirFeature
#endif
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_FILE_NAME
| GpgME::DecryptionResultFileNameFeature
#endif
#ifdef HAVE_GPGME_DECRYPT_RESULT_T_RECIPIENTS
| GpgME::DecryptionResultRecipientsFeature
#endif
#ifdef HAVE_GPGME_VERIFY_RESULT_T_FILE_NAME
| GpgME::VerificationResultFileNameFeature
#endif
#ifdef HAVE_GPGME_SIGNATURE_T_PKA_FIELDS
| GpgME::SignaturePkaFieldsFeature
#endif
#ifdef HAVE_GPGME_SIGNATURE_T_ALGORITHM_FIELDS
| GpgME::SignatureAlgorithmFieldsFeature
#endif
#ifdef HAVE_GPGME_GET_FDPTR
| GpgME::FdPointerFeature
#endif
#ifdef HAVE_GPGME_OP_GETAUDITLOG
| GpgME::AuditLogFeature
#endif
#ifdef HAVE_GPGME_PROTOCOL_GPGCONF
| GpgME::GpgConfEngineFeature
#endif
#ifdef HAVE_GPGME_CANCEL_ASYNC
| GpgME::CancelOperationAsyncFeature
#endif
#ifdef HAVE_GPGME_ENCRYPT_NO_ENCRYPT_TO
| GpgME::NoEncryptToEncryptionFlagFeature
#endif
#ifdef HAVE_GPGME_SUBKEY_T_IS_CARDKEY
| GpgME::CardKeyFeature
#endif
#ifdef HAVE_GPGME_ASSUAN_ENGINE
| GpgME::AssuanEngineFeature
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
| GpgME::EphemeralKeylistModeFeature
#endif
#ifdef HAVE_GPGME_OP_IMPORT_KEYS
| GpgME::ImportFromKeyserverFeature
#endif
#ifdef HAVE_GPGME_G13_VFS
| GpgME::G13VFSFeature
#endif
#ifdef HAVE_GPGME_OP_PASSWD
| GpgME::PasswdFeature
#endif
;
static const unsigned long supported_features2 = 0

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,8 +20,6 @@
Boston, MA 02110-1301, USA.
*/
#include <config-gpgme++.h>
#include <trustitem.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;
}
if (newmodes & GpgME::SignatureNotations) {
#ifdef HAVE_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) {
#ifdef HAVE_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) {
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) {
result |= GpgME::Signatures;
}
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
if (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS) {
result |= GpgME::SignatureNotations;
}
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
if (mode & GPGME_KEYLIST_MODE_EPHEMERAL) {
result |= GpgME::Ephemeral;
}
#endif
if (mode & GPGME_KEYLIST_MODE_VALIDATE) {
result |= GpgME::Validate;
}
#ifndef NDEBUG
if (mode & ~(GPGME_KEYLIST_MODE_LOCAL |
GPGME_KEYLIST_MODE_EXTERN |
#ifdef HAVE_GPGME_KEYLIST_MODE_SIG_NOTATIONS
GPGME_KEYLIST_MODE_SIG_NOTATIONS |
#endif
#ifdef HAVE_GPGME_KEYLIST_MODE_EPHEMERAL
GPGME_KEYLIST_MODE_EPHEMERAL |
#endif
GPGME_KEYLIST_MODE_VALIDATE |
GPGME_KEYLIST_MODE_SIGS)) {
//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)
{
#ifdef HAVE_GPGME_SIG_NOTATION_FLAGS_T
unsigned int result = 0;
#ifdef HAVE_GPGME_SIG_NOTATION_HUMAN_READABLE
if (flags & GPGME_SIG_NOTATION_HUMAN_READABLE) {
result |= GpgME::Notation::HumanReadable ;
}
#endif
#ifdef HAVE_GPGME_SIG_NOTATION_CRITICAL
if (flags & GPGME_SIG_NOTATION_CRITICAL) {
result |= GpgME::Notation::Critical ;
}
#endif
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)
{
unsigned int result = oldflags;
if (newflags & GpgME::Notation::HumanReadable) {
#ifdef HAVE_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) {
#ifdef HAVE_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);
}
#endif
#endif // __GPGMEPP_UTIL_H__

View File

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

View File

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