Commit 6eefa7d1 authored by Andre Heinecke's avatar Andre Heinecke

Handle gpgme_data_identify properly

This reduces the dependency back again to 1.1.7 as it
adds a check for data_identify. Additionally it checks for
the new binary and more fingrained version of gpgme_data_identify
that can actually be used and provides a feature check for
this.

This is a backport of GpgME commit: 15fc5c34
parent 1bc61d71
......@@ -195,7 +195,7 @@ else() # not WIN32
exec_program( ${_GPGMECONFIG_EXECUTABLE} ARGS --version OUTPUT_VARIABLE GPGME_VERSION )
set( _GPGME_MIN_VERSION "1.4.3" )
set( _GPGME_MIN_VERSION "1.1.7" )
if ( ${GPGME_VERSION} VERSION_LESS ${_GPGME_MIN_VERSION} )
......
......@@ -438,6 +438,30 @@ check_cxx_source_compiles ("
}
" HAVE_GPGME_CTX_OFFLINE )
# check if gpgme has identify support (new in 1.4.3)
check_cxx_source_compiles ("
#include <gpgme.h>
int main() {
gpgme_data_t data;
gpgme_data_identify( data, 0 );
return 0;
}
" HAVE_GPGME_DATA_IDENTIFY )
# check if gpgme has decent identify support (new in 1.7.0)
# decent means that it supports binary data and has more fine
# grained distinctions
check_cxx_source_compiles ("
#include <gpgme.h>
int main() {
gpgme_data_t data;
gpgme_data_type_t ret = gpgme_data_identify( data, 0 );
if (ret == GPGME_DATA_TYPE_PGP_SIGNATURE)
return 0;
return 0;
}
" HAVE_GPGME_DATA_IDENTIFY_GOOD )
# check if gpgme has pubkey_algo name mode support (new in 1.6.1)
check_function_exists ("gpgme_pubkey_algo_string" HAVE_GPGME_PUBKEY_ALGO_STRING )
......
......@@ -130,6 +130,12 @@ static inline void gpg_err_set_errno( int x ) { errno = x; }
/* Define to 1 if gpgme supports the context offline mode* */
#cmakedefine HAVE_GPGME_CTX_OFFLINE 1
/* Define to 1 if gpgme supports identify* */
#cmakedefine HAVE_GPGME_DATA_IDENTIFY 1
/* Define to 1 if gpgme supports a good version of identify* */
#cmakedefine HAVE_GPGME_DATA_IDENTIFY_GOOD 1
#ifndef GPGMEPP_ERR_SOURCE_DEFAULT
#define GPGMEPP_ERR_SOURCE_DEFAULT 22
#endif
......
......@@ -1684,6 +1684,9 @@ static const unsigned long supported_features = 0
;
static const unsigned long supported_features2 = 0
#ifdef HAVE_GPGME_IDENTIFY_GOOD
| GpgME::BinaryAndFineGrainedIdentify
#endif
;
bool GpgME::hasFeature(unsigned long features)
......
......@@ -169,6 +169,7 @@ GpgME::Data::Type GpgME::Data::type() const
if (isNull()) {
return Invalid;
}
#ifdef HAVE_GPGME_IDENTIFY
switch (gpgme_data_identify(d->data, 0)) {
case GPGME_DATA_TYPE_INVALID: return Invalid;
case GPGME_DATA_TYPE_UNKNOWN: return Unknown;
......@@ -180,8 +181,13 @@ GpgME::Data::Type GpgME::Data::type() const
case GPGME_DATA_TYPE_CMS_OTHER: return CMSOther;
case GPGME_DATA_TYPE_X509_CERT: return X509Cert;
case GPGME_DATA_TYPE_PKCS12: return PKCS12;
# ifdef HAVE_GPGME_IDENTIFY_GOOD
case GPGME_DATA_TYPE_PGP_ENCRYPTED: return PGPEncrypted;
case GPGME_DATA_TYPE_PGP_SIGNATURE: return PGPSignature;
# endif
}
return Invalid;
#endif
return Unknown;
}
char *GpgME::Data::fileName() const
......
......@@ -93,7 +93,9 @@ public:
CMSEncrypted,
CMSOther,
X509Cert,
PKCS12
PKCS12,
PGPEncrypted,
PGPSignature
};
Type type() const;
......
......@@ -132,8 +132,10 @@ enum Feature {
FeatureMaxValue = 0x80000000
};
enum Feature2 {
BinaryAndFineGrainedIdentify = 0x00000001, // gpgme >= 1.7.0
Feature2MaxValue = 0x80000000
};
// use hasFeature( unsigned long, unsigned long ) instead
GPGMEPP_DEPRECATED_EXPORT bool hasFeature(unsigned long feature);
GPGMEPP_EXPORT bool hasFeature(unsigned long feature, unsigned long feature2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment