Cpp: Add support for all EncryptionFlags

* lang/cpp/src/context.h (EncryptionFlags): Extend.
* lang/cpp/src/context.cpp (encryptflags2encryptflags): Ditto.
This commit is contained in:
Andre Heinecke 2016-08-09 13:07:30 +02:00
parent bf776ce94c
commit 1737239379
2 changed files with 26 additions and 1 deletions

View File

@ -1094,6 +1094,18 @@ static gpgme_encrypt_flags_t encryptflags2encryptflags(Context::EncryptionFlags
if (flags & Context::NoEncryptTo) { if (flags & Context::NoEncryptTo) {
result |= GPGME_ENCRYPT_NO_ENCRYPT_TO; result |= GPGME_ENCRYPT_NO_ENCRYPT_TO;
} }
if (flags & Context::Prepare) {
result |= GPGME_ENCRYPT_PREPARE;
}
if (flags & Context::ExpectSign) {
result |= GPGME_ENCRYPT_EXPECT_SIGN;
}
if (flags & Context::NoCompress) {
result |= GPGME_ENCRYPT_NO_COMPRESS;
}
if (flags & Context::Symmetric) {
result |= GPGME_ENCRYPT_SYMMETRIC;
}
return static_cast<gpgme_encrypt_flags_t>(result); return static_cast<gpgme_encrypt_flags_t>(result);
} }
@ -1395,6 +1407,11 @@ std::ostream &operator<<(std::ostream &os, Context::EncryptionFlags flags)
os << "GpgME::Context::EncryptionFlags("; os << "GpgME::Context::EncryptionFlags(";
#define CHECK( x ) if ( !(flags & (Context::x)) ) {} else do { os << #x " "; } while (0) #define CHECK( x ) if ( !(flags & (Context::x)) ) {} else do { os << #x " "; } while (0)
CHECK(AlwaysTrust); CHECK(AlwaysTrust);
CHECK(NoEncryptTo);
CHECK(Prepare);
CHECK(ExpectSign);
CHECK(NoCompress);
CHECK(Symmetric);
#undef CHECK #undef CHECK
return os << ')'; return os << ')';
} }

View File

@ -292,7 +292,15 @@ public:
// Encryption // Encryption
// //
enum EncryptionFlags { None = 0, AlwaysTrust = 1, NoEncryptTo = 2 }; enum EncryptionFlags {
None = 0,
AlwaysTrust = 1,
NoEncryptTo = 2,
Prepare = 4,
ExpectSign = 8,
NoCompress = 16,
Symmetric = 32
};
EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags); EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText); GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText);
GpgME::Error startEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags); GpgME::Error startEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);