merge branch JSON-97 to default

Claudio Luck 5 years ago
commit d2247f12f7

@ -52,6 +52,22 @@ std::string version_as_a_string()
}
#ifdef ENIGMAIL_2_0_COMPAT
// wrapper for Enigmail 2.0 to provide the old Engine's API before JSON-92 / ENGINE-423
PEP_STATUS MIME_decrypt_message_20(PEP_SESSION session, const char* src, size_t src_len, char** plaintext,
stringlist_t** keylist, PEP_rating* rating, PEP_decrypt_flags_t* flags)
{
*flags = 0;
char* modified_src = nullptr;
PEP_STATUS status = MIME_decrypt_message(session, src, src_len, plaintext, keylist, rating, flags, &modified_src);
pEp_free(modified_src);
return status;
}
#endif // ENIGMAIL_2_0_COMPAT
using In_Pep_Session = In<PEP_SESSION, ParamFlag::NoInput>;
@ -64,9 +80,14 @@ const FunctionMap functions = {
FP( "MIME_encrypt_message_for_self", new Func<PEP_STATUS, In_Pep_Session,
In<pEp_identity*>, In<c_string>, InLength<>, In<stringlist_t*>,
Out<char*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>( &MIME_encrypt_message_for_self ) ),
#ifdef ENIGMAIL_2_0_COMPAT
FP( "MIME_decrypt_message", new Func<PEP_STATUS, In_Pep_Session, In<c_string>, InLength<>,
Out<char*>, Out<stringlist_t*>, Out<PEP_rating>, Out<PEP_decrypt_flags_t>>( &MIME_decrypt_message_20 ) ),
#else
FP( "MIME_decrypt_message", new Func<PEP_STATUS, In_Pep_Session, In<c_string>, InLength<>,
Out<char*>, InOutP<stringlist_t*>, Out<PEP_rating>, InOutP<PEP_decrypt_flags_t>, Out<c_string>>( &MIME_decrypt_message ) ),
#endif
FP( "startKeySync", new Func<void, In<JsonAdapter*,ParamFlag::NoInput>>( &JsonAdapter::startSync) ),
FP( "stopKeySync", new Func<void, In<JsonAdapter*,ParamFlag::NoInput>>( &JsonAdapter::stopSync ) ),
@ -76,8 +97,12 @@ const FunctionMap functions = {
FP( "encrypt_message", new Func<PEP_STATUS, In_Pep_Session, In<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>( &encrypt_message ) ),
FP( "encrypt_message_for_self", new Func<PEP_STATUS, In_Pep_Session,
In<pEp_identity*>, In<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>( &encrypt_message_for_self ) ),
#ifdef ENIGMAIL_2_0_COMPAT
FP( "decrypt_message", new Func<PEP_STATUS, In_Pep_Session, In<message*>, Out<message*>, Out<stringlist_t*>, Out<PEP_rating>, Out<PEP_decrypt_flags_t>>( &decrypt_message ) ),
#else
FP( "decrypt_message", new Func<PEP_STATUS, In_Pep_Session, InOut<message*>, Out<message*>, InOutP<stringlist_t*>, Out<PEP_rating>, InOutP<PEP_decrypt_flags_t>>( &decrypt_message ) ),
#endif
FP( "outgoing_message_rating", new Func<PEP_STATUS, In_Pep_Session, In<message*>, Out<PEP_rating>>( &outgoing_message_rating ) ),
FP( "identity_rating" , new Func<PEP_STATUS, In_Pep_Session, In<pEp_identity*>, Out<PEP_rating>>( &identity_rating) ),

@ -10,7 +10,10 @@
#include <thread>
#include <sstream>
#include <vector>
#include <alloca>
#ifdef _WIN32
# include <alloca>
#endif
#ifdef LOGGER_ENABLE_SYSLOG
extern "C" {

@ -1,6 +1,7 @@
#include "pep-types.hh"
#include "pep-utils.hh"
#include "pep-utils-json.hh"
#include "json-adapter.hh"
#include <pEp/pEp_string.h>
#include <iostream> // Just to print debug stuff to std::cerr

@ -74,7 +74,12 @@ static const std::string VersionName =
//const ServerVersion sv(0,14,0); // JSON-75: incompatible behavior of daemonize() especially in MS Windows
//const ServerVersion sv(0,15,0); // JSON-92: API CHANGE.
//const ServerVersion sv(0,15,1); // JSON-92 again: Change "keylist" in (MIME_)decrypt_message() from Out to InOutP. Is a compatible API change for JSON/JavaScript due to the handling of output parameters. :-)
#ifdef ENIGMAIL_2_0_COMPAT
const ServerVersion sv(0,14,1); // JSON-97 : make MIME_decrypt_message() API-compatible with pre-JSON-92's changes for Enigmail 2.0
#else
const ServerVersion sv(0,15,2); // JSON-93 InLength<> is a compatible API change, because length parameter is still there but ignored. :-)
#endif // ENIGMAIL_2_0_COMPAT
} // end of anonymous namespace
////////////////////////////////////////////////////////////////////////////
@ -87,18 +92,26 @@ ServerVersion::ServerVersion(unsigned maj, unsigned min, unsigned p)
, package_version{PackageVersion}
{
if (!PackageVersion)
try{
PackageVersion = "0.0.0"; /* break the loop */
const std::string file_content =
boost::algorithm::trim_copy(
pEp::utility::slurp("PackageVersion")
);
js::Value v;
js::read_or_throw(file_content, v);
const js::Object obj = v.get_obj();
PackageVersion = pEp::utility::from_json_object<char*, js::str_type>(obj, "package_version");
PackageVersion = strdup(file_content.c_str());
try{
js::Value v;
js::read_or_throw(file_content, v);
const js::Object obj = v.get_obj();
PackageVersion = pEp::utility::from_json_object<char*, js::str_type>(obj, "package_version");
}
catch(std::runtime_error&)
{
PackageVersion = strdup(file_content.c_str());
}
this->package_version = PackageVersion;
}
catch(std::runtime_error&)

Loading…
Cancel
Save