"(11) Köln-Klettenberg"; // support for identity_list as output parameter, as needed by import_key() now. Fix some issue with identity.lang

refactor-result-recursion
Roker 7 years ago
parent 76c5cc87a0
commit d3bfe6c8a8

@ -331,10 +331,17 @@ function button_click()
displayResult(moo);
})
.fail(function( hdr, txt, err) {
alert( "Ajax POST request returns an: \n"
+ "Header: " + JSON.stringify(hdr) + "\n"
+ "Text: " + JSON.stringify(txt) + "\n"
+ "Error:" + JSON.stringify(err) + "\n" );
var emsg =
"\nAjax POST request returns an: \n"
+ "Header: " + JSON.stringify(hdr, null, 2) + "\n"
+ "Text: " + JSON.stringify(txt, null, 2) + "\n"
+ "Error:" + JSON.stringify(err, null, 2) + "\n";
var pre = document.getElementById("resultpre");
pre.innerHTML += emsg;
pre.className = "red";
alert(emsg);
})
;

@ -35,6 +35,24 @@ In<std::size_t>::~In()
{ }
#define SIMPLE_TYPE_OUT(TYPE) \
template<> \
Out< TYPE >::~Out() \
{ \
delete value; \
} \
\
template<> \
Out< TYPE >::Out(const Out<TYPE>& other) \
: value ( new TYPE {*other.value} ) \
{ }
SIMPLE_TYPE_OUT( bool )
SIMPLE_TYPE_OUT( unsigned )
SIMPLE_TYPE_OUT( unsigned long)
SIMPLE_TYPE_OUT( unsigned long long)
template<>
Out<char const*>::~Out()
{
@ -58,25 +76,6 @@ Out<char*>::~Out()
}
template<>
Out<std::size_t>::~Out()
{
delete value;
}
template<>
Out<bool>::Out(const Out<bool>& other)
: value ( new bool {*other.value} )
{
}
template<>
Out<bool>::~Out()
{
delete value;
}
template<>
Out<char const*>::Out(const Out<const char*>& other)
@ -93,13 +92,6 @@ Out<char*>::Out(const Out<char*>& other)
}
template<>
Out<std::size_t>::Out(const Out<std::size_t>& other)
: value( new std::size_t(*other.value))
{
}
template<>
int from_json<int>(const js::Value& v)
{
@ -195,14 +187,25 @@ js::Value Type2String<const char*>::get() { return "String"; }
template<>
js::Value Type2String<char*>::get() { return "String"; }
template<>
js::Value Type2String<int>::get() { return "Integer"; }
template<>
js::Value Type2String<size_t>::get() { return "Integer"; }
js::Value Type2String<long>::get() { return "Integer"; }
template<>
js::Value Type2String<long long>::get() { return "Integer"; }
template<>
js::Value Type2String<unsigned>::get() { return "Integer"; }
template<>
js::Value Type2String<unsigned long>::get() { return "Integer"; }
template<>
js::Value Type2String<time_t>::get() { return "Integer"; }
js::Value Type2String<unsigned long long>::get() { return "Integer"; }
template<>
js::Value Type2String<bool>::get() { return "Bool"; }

@ -52,7 +52,8 @@ const std::string server_version =
// "(8) Kerpen"; // pEp_identity fixes due to changes in the pEp Engine
// "(8a) Kreuz Kerpen"; // remove own_key_add() because pEpEngine doesn't have it anymore.
// "(9a) Frechen-Königsdorf"; // add security-token
"(10) Kreuz Köln-West"; // More fields in JavaScript for "message", 1-element identity list to support message->to attribute
// "(10) Kreuz Köln-West"; // More fields in JavaScript for "message", 1-element identity list to support message->to attribute
"(11) Köln-Klettenberg"; // support for identity_list as output parameter, as needed by import_key() now. Fix some issue with identity.lang
template<>
@ -126,7 +127,7 @@ const FunctionMap functions = {
// from message_api.h
FP( "—— Message API ——", new Separator ),
FP( "encrypt_message", new Func<PEP_STATUS, In<PEP_SESSION>, In<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>>( &encrypt_message ) ),
FP( "decrypt_message", new Func<PEP_STATUS, In<PEP_SESSION>, In<message*>, Out<message*>, Out<stringlist_t*>, Out<PEP_color>>( &decrypt_message ) ),
FP( "decrypt_message", new Func<PEP_STATUS, In<PEP_SESSION>, In<message*>, Out<message*>, Out<stringlist_t*>, Out<PEP_color>, Out<PEP_decrypt_flags_t>>( &decrypt_message ) ),
FP( "outgoing_message_color", new Func<PEP_STATUS, In<PEP_SESSION>, In<message*>, Out<PEP_color>>( &outgoing_message_color ) ),
FP( "identity_color" , new Func<PEP_STATUS, In<PEP_SESSION>, In<pEp_identity*>, Out<PEP_color>>( &identity_color) ),
FP( "get_gpg_path", new Func<PEP_STATUS, Out<const char*>>(&get_gpg_path) ),
@ -145,7 +146,7 @@ const FunctionMap functions = {
FP( "—— Low level Key Management API ——", new Separator),
FP( "generate_keypair", new Func<PEP_STATUS, In<PEP_SESSION>, InOut<pEp_identity*>> ( &generate_keypair) ),
FP( "delete_keypair", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>> ( &delete_keypair) ),
FP( "import_key" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<std::size_t>> ( &import_key) ),
FP( "import_key" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<std::size_t>, Out<identity_list*>> ( &import_key) ),
FP( "export_key" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, Out<char*>, Out<std::size_t>> ( &export_key) ),
FP( "find_keys" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, Out<stringlist_t*>> ( &find_keys) ),
FP( "get_trust" , new Func<PEP_STATUS, In<PEP_SESSION>, InOut<pEp_identity*>> ( &get_trust) ),

@ -82,6 +82,16 @@ Out<pEp_identity*>::~Out()
delete value;
}
template<>
Out<identity_list*>::~Out()
{
if(value)
{
free_identity_list(*value);
}
delete value;
}
template<>
In<pEp_identity*>::In(const In<pEp_identity*>& other)
@ -100,6 +110,17 @@ Out<pEp_identity*>::Out(const Out<pEp_identity*>& other)
}
template<>
Out<_identity_list*>::Out(const Out<identity_list*>& other)
: value( new identity_list*{} )
{
if(*other.value)
{
*value = identity_list_dup(*other.value);
}
}
template<>
In<PEP_enc_format>::~In()
{
@ -229,9 +250,9 @@ pEp_identity* from_json<pEp_identity*>(const js::Value& v)
free(address);
ident->comm_type = from_json_object<PEP_comm_type, js::int_type>(o, "comm_type");
if(lang)
if(lang && lang[0] && lang[1])
{
strncpy(ident->lang, lang, 3);
strncpy(ident->lang, lang, 3);
free(lang);
}
ident->me = from_json_object<bool, js::bool_type>(o, "me");
@ -441,7 +462,10 @@ js::Value to_json<pEp_identity*>(pEp_identity* const& id)
to_json_object(o, "username", id->username);
o.emplace_back( "comm_type", js::Value( int( id->comm_type) ));
o.emplace_back( "lang", js::Value( std::string( id->lang, id->lang+2) ));
if(id->lang && id->lang[0] && id->lang[1])
o.emplace_back( "lang", js::Value( std::string( id->lang, id->lang+2) ));
o.emplace_back( "me", js::Value( id->me ));
return js::Value( std::move(o) );
@ -535,6 +559,9 @@ js::Value Type2String<const timestamp*>::get() { return "Timestamp"; }
template<>
js::Value Type2String<pEp_identity*>::get() { return "Identity"; }
template<>
js::Value Type2String<identity_list*>::get() { return "IdentityList"; }
template<>
js::Value Type2String<_stringlist_t*>::get() { return "StringList"; }

Loading…
Cancel
Save