add support for the remaining functions from pEpEngine.h

refactor-result-recursion
Lars Rohwedder 7 years ago
parent 93517566e2
commit da9f2554b3

@ -27,6 +27,11 @@ In<int>::~In()
{
}
template<>
In<std::size_t>::~In()
{
}
template<>
Out<char const*>::~Out()
@ -44,12 +49,27 @@ Out<char*>::~Out()
delete value;
}
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)
: value( new const char* )
@ -160,3 +180,6 @@ js::Value Type2String<int>::get() { return "Integer"; }
template<>
js::Value Type2String<size_t>::get() { return "Integer"; }
template<>
js::Value Type2String<bool>::get() { return "Bool"; }

@ -43,7 +43,8 @@ const std::string server_version =
// "(4) Kreuz Aachen"; // first version with this version scheme :-)
// "(5a) Eschweiler-West"; // add support for log_event() and trustwords()
// "(5b) Eschweiler-Ost"; // add support for get_identity() and get_languagelist()
"(5c) Weisweiler"; // add missing members of struct message
// "(5c) Weisweiler"; // add missing members of struct message
"(5d) Langerwehe"; // add the remaining functions from pEpEngine.h
template<>
@ -142,6 +143,26 @@ const FunctionMap functions = {
FP( "trustwords", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<const char*>, Out<char*>, Out<size_t>, In<int>>( &trustwords) ),
FP( "get_languagelist", new Func<PEP_STATUS, In<PEP_SESSION>, Out<char*>>( &get_languagelist) ),
FP( "get_identity", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, Out<pEp_identity*>>( &get_identity) ),
FP( "set_identity", new Func<PEP_STATUS, In<PEP_SESSION>, In<pEp_identity*>> ( &set_identity) ),
FP( "mark_as_comprimized", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>> ( &mark_as_compromized) ),
// InOut<> is not yet supported
FP( "generate_keypair", new Separator /*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( "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) ),
// InOut<> is not yet supported
FP( "get_trust", new Separator /* new Func<PEP_STATUS, In<PEP_SESSION>, InOut<pEp_identity*>> ( &get_trust) */ ),
FP( "least_trust" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, Out<PEP_comm_type>> ( &least_trust) ),
FP( "get_key_rating", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, Out<PEP_comm_type>> ( &get_key_rating) ),
FP( "renew_key" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<const timestamp*>> ( &renew_key) ),
FP( "revoke" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<const char*>> ( &revoke_key) ),
FP( "key_expired" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, Out<bool>> ( &key_expired) ),
FP( "get_phrase" , new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<int>, Out<char*>> ( &get_phrase) ),
// my own example function that does something useful. :-)
FP( "—— Other ——", new Separator ),

@ -29,6 +29,13 @@ namespace
}
template<>
In<const timestamp*>::~In()
{
free_timestamp(const_cast<timestamp*>(value)); // FIXME: is that const_cast okay?
}
template<>
In<message*>::~In()
{
@ -114,6 +121,19 @@ Out<PEP_color>::~Out()
}
template<>
Out<PEP_comm_type>::Out(const Out<PEP_comm_type>& other)
: value( new PEP_comm_type(*other.value) )
{
}
template<>
Out<PEP_comm_type>::~Out()
{
delete value;
}
template<>
message* from_json<message*>(const js::Value& v)
{
@ -340,6 +360,13 @@ tm* from_json<tm*>(const js::Value& v)
return new_timestamp( v.get_int64() );
}
template<>
const tm* from_json<const tm*>(const js::Value& v)
{
return new_timestamp( v.get_int64() );
}
template<>
js::Value to_json<stringlist_t*>(stringlist_t* const& osl)
{
@ -442,6 +469,18 @@ js::Value to_json<PEP_msg_direction>(const PEP_msg_direction& v)
return js::Value( int(v) );
}
template<>
PEP_comm_type from_json<PEP_comm_type>(const js::Value& v)
{
return PEP_comm_type(v.get_int());
}
template<>
js::Value to_json<PEP_comm_type>(const PEP_comm_type& v)
{
return js::Value( int(v) );
}
template<>
js::Value Type2String<PEP_SESSION>::get() { return "Session"; }
@ -449,6 +488,9 @@ js::Value Type2String<PEP_SESSION>::get() { return "Session"; }
template<>
js::Value Type2String<_message*>::get() { return "Message"; }
template<>
js::Value Type2String<const timestamp*>::get() { return "Timestamp"; }
template<>
js::Value Type2String<pEp_identity*>::get() { return "Identity"; }
@ -461,6 +503,9 @@ js::Value Type2String<_PEP_color>::get() { return "PEP_color"; }
template<>
js::Value Type2String<_PEP_enc_format>::get() { return "PEP_enc_format"; }
template<>
js::Value Type2String<_PEP_comm_type>::get() { return "PEP_comm_type"; }
template<>
js::Value Type2String<PEP_STATUS>::get() { return "PEP_STATUS"; }

Loading…
Cancel
Save