From 0430d3a703a7ae3181ffe89c4004d74ffd5c2c41 Mon Sep 17 00:00:00 2001 From: Roker Date: Wed, 5 Oct 2016 16:54:41 +0200 Subject: [PATCH] JSON-6 implement interface changes minimally, so it compiles at least. --- server/Makefile | 6 +++--- server/json-adapter.cc | 26 +++++++++++++++----------- server/json-adapter.hh | 4 ++-- server/pep-types.cc | 8 ++++---- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/server/Makefile b/server/Makefile index 0b95750..3fc5032 100644 --- a/server/Makefile +++ b/server/Makefile @@ -7,13 +7,13 @@ ifeq ($(BUILD_ON),Darwin) ifeq ($(BUILD_FOR),Darwin) CXXFLAGS = -I/opt/local/include -I$(HOME)/include -Ijson_spirit -LDFLAGS = -L/opt/local/lib -L$(HOME)/lib -lpthread -levent -lpEpEngine -lgpgme-pthread -letpan -lboost_system-mt -lboost_filesystem-mt +LDFLAGS = -L/opt/local/lib -L$(HOME)/lib -lpthread -levent -lpEpEngine -luuid -lgpgme-pthread -letpan -lboost_system-mt -lboost_filesystem-mt endif else CXXFLAGS = -I$(HOME)/include -I$(HOME)/local/include/ -Ijson_spirit -LDFLAGS = -L$(HOME)/lib -L$(HOME)/local/lib -lpthread -levent -lpEpEngine -lgpgme-pthread -letpan -lboost_system -lboost_filesystem +LDFLAGS = -L$(HOME)/lib -L$(HOME)/local/lib -lpthread -levent -lpEpEngine -luuid -lgpgme-pthread -letpan -lboost_system -lboost_filesystem endif @@ -22,7 +22,7 @@ endif all: mt-server mt-server: main.o libjson-adapter.a - $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) ../../pEpEngine/asn.1/libasn1.a + $(CXX) $(CXXFLAGS) -o $@ $^ ../../pEpEngine/asn.1/libasn1.a $(LDFLAGS) libjson-adapter.a: json-adapter.o registry.o nfc.o json_rpc.o \ diff --git a/server/json-adapter.cc b/server/json-adapter.cc index 3ce7c10..2c5c9ce 100644 --- a/server/json-adapter.cc +++ b/server/json-adapter.cc @@ -126,10 +126,10 @@ const FunctionMap functions = { // from message_api.h FP( "—— Message API ——", new Separator ), - FP( "encrypt_message", new Func, In, In, Out, In>( &encrypt_message ) ), - FP( "decrypt_message", new Func, In, Out, Out, Out, Out>( &decrypt_message ) ), - FP( "outgoing_message_color", new Func, In, Out>( &outgoing_message_color ) ), - FP( "identity_color" , new Func, In, Out>( &identity_color) ), + FP( "encrypt_message", new Func, In, In, Out, In, In>( &encrypt_message ) ), + FP( "decrypt_message", new Func, In, Out, Out, Out, Out>( &decrypt_message ) ), + FP( "outgoing_message_color", new Func, In, Out>( &outgoing_message_rating ) ), + FP( "identity_color" , new Func, In, Out>( &identity_rating) ), FP( "get_gpg_path", new Func>(&get_gpg_path) ), FP( "—— pEp Engine Core API ——", new Separator), @@ -152,7 +152,6 @@ const FunctionMap functions = { FP( "find_keys" , new Func, In, Out> ( &find_keys) ), FP( "get_trust" , new Func, InOut> ( &get_trust) ), FP( "own_key_is_listed", new Func, In, Out> ( &own_key_is_listed) ), - FP( "own_key_retrieve" , new Func, Out> ( &own_key_retrieve) ), FP( "least_trust" , new Func, In, Out> ( &least_trust) ), FP( "get_key_rating", new Func, In, Out> ( &get_key_rating) ), @@ -163,7 +162,7 @@ const FunctionMap functions = { FP( "-- Event Listener & Results", new Separator ), FP( "registerEventListener" , new Func, In, In, In> ( ®isterEventListener) ), FP( "unregisterEventListener", new Func, In, In, In> ( &unregisterEventListener) ), - FP( "deliverHandshakeResult" , new Func, In> (&deliverHandshakeResult) ), + FP( "deliverHandshakeResult" , new Func, In, In> (&deliverHandshakeResult) ), // my own example function that does something useful. :-) FP( "—— Other ——", new Separator ), @@ -455,7 +454,7 @@ struct JsonAdapter::Internal return (ret == 0) ? PEP_STATUS_OK : PEP_UNKNOWN_ERROR; } - PEP_STATUS messageToSend(const message* msg) + PEP_STATUS messageToSend(message* msg) { js::Value js_msg = to_json(msg); js::Array param; @@ -473,10 +472,11 @@ struct JsonAdapter::Internal } } + free_message(msg); return status; } - PEP_STATUS showHandshake(const pEp_identity* self, const pEp_identity* partner) + PEP_STATUS showHandshake(pEp_identity* self, pEp_identity* partner) { // TODO: eliminate redundancy to messageToSend() above js::Array param; @@ -495,19 +495,22 @@ struct JsonAdapter::Internal } } + free_identity(self); + free_identity(partner); + return status; } }; -PEP_STATUS JsonAdapter::messageToSend(void* obj, const message* msg) +PEP_STATUS JsonAdapter::messageToSend(void* obj, message* msg) { JsonAdapter* ja = static_cast(obj); return ja->i->messageToSend(msg); } -PEP_STATUS JsonAdapter::showHandshake(void* obj, const pEp_identity* self, const pEp_identity* partner) +PEP_STATUS JsonAdapter::showHandshake(void* obj, pEp_identity* self, pEp_identity* partner) { JsonAdapter* ja = static_cast(obj); return ja->i->showHandshake(self, partner); @@ -562,7 +565,8 @@ try session_registry.emplace( id, session); std::cerr << "\tcreated new session for this thread: " << static_cast(session) << ".\n"; - register_sync_callbacks( session, this, &messageToSend, &showHandshake ); + // TODO: 5th parameter inject_sync_msg_t, and 6th parameter retrieve_next_sync_msg_t missing* + register_sync_callbacks( session, this, &messageToSend, &showHandshake, nullptr, nullptr ); }else{ std::cerr << "\tsession for this thread: " << static_cast(q->second) << ".\n"; } diff --git a/server/json-adapter.hh b/server/json-adapter.hh index b772a6b..0bbeed3 100644 --- a/server/json-adapter.hh +++ b/server/json-adapter.hh @@ -50,8 +50,8 @@ public: static std::string version(); - static PEP_STATUS messageToSend(void* obj, const message* msg); - static PEP_STATUS showHandshake(void* obj, const pEp_identity* self, const pEp_identity* partner); + static PEP_STATUS messageToSend(void* obj, message* msg); + static PEP_STATUS showHandshake(void* obj, pEp_identity* self, pEp_identity* partner); private: struct Internal; diff --git a/server/pep-types.cc b/server/pep-types.cc index fb64c32..ebd7a10 100644 --- a/server/pep-types.cc +++ b/server/pep-types.cc @@ -140,7 +140,7 @@ Out<_message*>::~Out() template<> -Out::~Out() +Out::~Out() { delete value; } @@ -506,10 +506,10 @@ js::Value to_json(identity_list* const& idl) template<> -js::Value to_json(const PEP_color& color) +js::Value to_json(const PEP_rating& rating) { js::Object o; - o.emplace_back( "color", int(color) ); + o.emplace_back( "color", int(rating) ); return o; } @@ -588,7 +588,7 @@ template<> js::Value Type2String<_stringlist_t*>::get() { return "StringList"; } template<> -js::Value Type2String<_PEP_color>::get() { return "PEP_color"; } +js::Value Type2String<_PEP_rating>::get() { return "PEP_rating"; } template<> js::Value Type2String<_PEP_enc_format>::get() { return "PEP_enc_format"; }