From a9a9d8fbbb9b2c5c1b40b63439497b0b195a0b08 Mon Sep 17 00:00:00 2001 From: Luca Saiu as luca from a local script Date: Thu, 13 Jul 2023 17:06:30 +0200 Subject: [PATCH] make send_ping, now an Engine API function, available to Python Also update the Engine entry in DEPENDENCIES. --- DEPENDENCIES | 2 +- src/pEp/_pEp/basic_api.cc | 17 +++++++++++++++++ src/pEp/_pEp/basic_api.hh | 2 ++ src/pEp/_pEp/pEpmodule.cc | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index a7d0407..f6ba050 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,6 +1,6 @@ # 1st Party Dependencies ## Prefer git tags instead of SHA hashes when possible. -pEpEngine=v3.3.0-RC7 +pEpEngine=v3.3.0-RC10 libpEpAdapter= v3.2.0-RC5 libpEpCxx=v3.2.0-RC1 diff --git a/src/pEp/_pEp/basic_api.cc b/src/pEp/_pEp/basic_api.cc index 87c20a9..c738d8f 100644 --- a/src/pEp/_pEp/basic_api.cc +++ b/src/pEp/_pEp/basic_api.cc @@ -7,6 +7,7 @@ // Engine #include #include +#include #include // local @@ -221,5 +222,21 @@ namespace pEp { _throw_status(status); } + void send_ping(Identity &own_identity, Identity &other_identity) + { + const std::string own_userid = (*own_identity).user_id; + if (own_userid == "") + throw invalid_argument("user_id needed for own identity"); + else if (own_userid != PEP_OWN_USERID) + throw invalid_argument("suppesedly own identity not own"); + + ::pEp_identity *own_identity_c = own_identity; + ::pEp_identity *other_identity_c = other_identity; + + PEP_STATUS status = PEP_STATUS_OK; + status = ::send_ping(Adapter::session(), own_identity_c, other_identity_c); + _throw_status(status); + } + } // namespace PythonAdapter } // namespace pEp diff --git a/src/pEp/_pEp/basic_api.hh b/src/pEp/_pEp/basic_api.hh index 1320be4..579c007 100644 --- a/src/pEp/_pEp/basic_api.hh +++ b/src/pEp/_pEp/basic_api.hh @@ -34,6 +34,8 @@ namespace pEp { void set_own_key(Identity &ident, string fpr); void set_comm_partner_key(Identity &ident, string fpr); + + void send_ping(Identity &own_identity, Identity &other_identity); } /* namespace PythonAdapter */ } /* namespace pEp */ diff --git a/src/pEp/_pEp/pEpmodule.cc b/src/pEp/_pEp/pEpmodule.cc index 86c1d6e..53bbb5d 100644 --- a/src/pEp/_pEp/pEpmodule.cc +++ b/src/pEp/_pEp/pEpmodule.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include // libpEpAdapter @@ -695,6 +696,19 @@ namespace pEp { "ident partner identity this key is used for\n" "fpr fingerprint of the key to set as the identity default\n"); + def("send_ping", + &send_ping, + "send_ping(own_identity, other_identity)\n" + "\n" + "send a Distribution.Ping message from the given own identity\n" + "to the given identity, usually but not necessarily non-own.\n" + "\n" + "Both identities must have been updated, the own identity\n" + "with pEp.myself() and the second with Identity.update()\n" + "\n" + "own_identity the sender identity\n" + "other_identity the recipient identity\n"); + // message API enum_("rating")