summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2016-06-27 15:48:13 +0200
committerAndre Heinecke <[email protected]>2016-06-27 15:51:40 +0200
commit6eefa7d15dbe59b70447a7efb077a652d9e27934 (patch)
tree9b9b9a1c44b6d391ca4ad6fd3000f064c3765052
parent1bc61d71db86c28c4306aed129f133a2c3cce6e9 (diff)
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
-rw-r--r--cmake/FindGpgme.cmake2
-rw-r--r--src/ConfigureChecks.cmake24
-rw-r--r--src/config-gpgme++.h.cmake6
-rw-r--r--src/context.cpp3
-rw-r--r--src/data.cpp8
-rw-r--r--src/data.h4
-rw-r--r--src/global.h2
7 files changed, 46 insertions, 3 deletions
diff --git a/cmake/FindGpgme.cmake b/cmake/FindGpgme.cmake
index 8656b9f..c5f8470 100644
--- a/cmake/FindGpgme.cmake
+++ b/cmake/FindGpgme.cmake
@@ -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} )
diff --git a/src/ConfigureChecks.cmake b/src/ConfigureChecks.cmake
index 0145c46..e7822a9 100644
--- a/src/ConfigureChecks.cmake
+++ b/src/ConfigureChecks.cmake
@@ -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 )
diff --git a/src/config-gpgme++.h.cmake b/src/config-gpgme++.h.cmake
index 5d1cbd2..1e19507 100644
--- a/src/config-gpgme++.h.cmake
+++ b/src/config-gpgme++.h.cmake
@@ -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
diff --git a/src/context.cpp b/src/context.cpp
index c1241e5..efdcf71 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -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)
diff --git a/src/data.cpp b/src/data.cpp
index f2fdcd5..91e8377 100644
--- a/src/data.cpp
+++ b/src/data.cpp
@@ -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
diff --git a/src/data.h b/src/data.h
index 231bf98..a893292 100644
--- a/src/data.h
+++ b/src/data.h
@@ -93,7 +93,9 @@ public:
CMSEncrypted,
CMSOther,
X509Cert,
- PKCS12
+ PKCS12,
+ PGPEncrypted,
+ PGPSignature
};
Type type() const;
diff --git a/src/global.h b/src/global.h
index c996eca..0b86fa5 100644
--- a/src/global.h
+++ b/src/global.h
@@ -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);