add support for log_event() and trustwords()

refactor-result-recursion
Lars Rohwedder 7 years ago
parent d9bf48f4de
commit f32bcc122a

@ -16,6 +16,18 @@ namespace
}
template<>
In<char const*>::~In()
{
if(value) free(const_cast<char*>(value));
}
template<>
In<int>::~In()
{
}
template<>
Out<char const*>::~Out()
{
@ -23,6 +35,21 @@ Out<char const*>::~Out()
delete value;
}
template<>
Out<char*>::~Out()
{
if(value) free(*value);
*value = nullptr;
delete value;
}
template<>
Out<std::size_t>::~Out()
{
delete value;
}
template<>
Out<char const*>::Out(const Out<const char*>& other)
: value( new const char* )
@ -30,6 +57,20 @@ Out<char const*>::Out(const Out<const char*>& other)
*value = *other.value ? strdup(*other.value) : nullptr;
}
template<>
Out<char*>::Out(const Out<char*>& other)
: value( new char* )
{
*value = *other.value ? strdup(*other.value) : nullptr;
}
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)
@ -56,6 +97,12 @@ char* from_json<char*>(const js::Value& v)
return make_c_string( v.get_str() );
}
template<>
const char* from_json<const char*>(const js::Value& v)
{
return make_c_string( v.get_str() );
}
template<class T>
js::Value to_json(const T& t)
@ -86,9 +133,24 @@ js::Value to_json<const char*>(const char* const & s)
return s ? js::Value(std::string(s)) : js::Value{};
}
template<>
js::Value to_json<std::size_t>(const std::size_t& s)
{
return js::Value{s};
}
template<>
js::Value Type2String<std::string>::get() { return "String"; }
template<>
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"; }

@ -40,8 +40,9 @@ const std::string ApiRequestUrl = BaseUrl + "callFunction";
// version names comes from here:
// https://de.wikipedia.org/wiki/Bundesautobahn_4
const std::string server_version =
"(4) Kreuz Aachen"; // first version with this version scheme :-)
// "(4) Kreuz Aachen"; // first version with this version scheme :-)
"(5a) Eschweiler-West"; // add support for log_event() and trustwords()
template<>
In<PEP_SESSION>::~In()
@ -132,8 +133,11 @@ const FunctionMap functions = {
FP( "decrypt_message", new Func<PEP_STATUS, In<PEP_SESSION>, In<message*>, Out<message*>, Out<stringlist_t*>, Out<PEP_color>>( &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) ),
FP( "get_gpg_path", new Func<PEP_STATUS, Out<const char*>>(&get_gpg_path) ),
FP( "—— pEp Engine Core API ——", new Separator),
FP( "log_event", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<const char*>, In<const char*>, In<const char*>>( &log_event) ),
FP( "trustwords", new Func<PEP_STATUS, In<PEP_SESSION>, In<const char*>, In<const char*>, Out<char*>, Out<size_t>, In<int>>( &trustwords) ),
// my own example function that does something useful. :-)
FP( "—— Other ——", new Separator ),

Loading…
Cancel
Save