Cpp: Add support for gpgme_data_identify

* lang/cpp/src/data.cpp (Data::type): New.
* lang/cpp/src/data.h (Data::Type): New enum mapping.
This commit is contained in:
Andre Heinecke 2016-04-12 16:05:31 +02:00
parent 6dba47c3a2
commit d949d711dc
2 changed files with 34 additions and 0 deletions

View File

@ -162,6 +162,26 @@ GpgME::Error GpgME::Data::setEncoding(Encoding enc)
return Error(gpgme_data_set_encoding(d->data, ge)); return Error(gpgme_data_set_encoding(d->data, ge));
} }
GpgME::Data::Type GpgME::Data::type() const
{
if (isNull()) {
return Invalid;
}
switch (gpgme_data_identify(d->data, 0)) {
case GPGME_DATA_TYPE_INVALID: return Invalid;
case GPGME_DATA_TYPE_UNKNOWN: return Unknown;
case GPGME_DATA_TYPE_PGP_SIGNED: return PGPSigned;
case GPGME_DATA_TYPE_PGP_OTHER: return PGPOther;
case GPGME_DATA_TYPE_PGP_KEY: return PGPKey;
case GPGME_DATA_TYPE_CMS_SIGNED: return CMSSigned;
case GPGME_DATA_TYPE_CMS_ENCRYPTED: return CMSEncrypted;
case GPGME_DATA_TYPE_CMS_OTHER: return CMSOther;
case GPGME_DATA_TYPE_X509_CERT: return X509Cert;
case GPGME_DATA_TYPE_PKCS12: return PKCS12;
}
return Invalid;
}
char *GpgME::Data::fileName() const char *GpgME::Data::fileName() const
{ {
return gpgme_data_get_file_name(d->data); return gpgme_data_get_file_name(d->data);

View File

@ -82,6 +82,20 @@ public:
Encoding encoding() const; Encoding encoding() const;
Error setEncoding(Encoding encoding); Error setEncoding(Encoding encoding);
enum Type {
Invalid,
Unknown,
PGPSigned,
PGPOther,
PGPKey,
CMSSigned,
CMSEncrypted,
CMSOther,
X509Cert,
PKCS12
};
Type type() const;
char *fileName() const; char *fileName() const;
Error setFileName(const char *name); Error setFileName(const char *name);