Browse Source

remove keyserver lookup functionality

Remove keyserver lookup functionality.  Simplify brutally.
JSON-955
Luca Saiu 3 months ago
parent
commit
9d14e95f42
3 changed files with 0 additions and 109 deletions
  1. +0
    -13
      API reference details.md
  2. +0
    -82
      server/mini-adapter-impl.cc
  3. +0
    -14
      server/mini-adapter-impl.hh

+ 0
- 13
API reference details.md View File

@ -114,12 +114,6 @@ Start Key Synchronization for the current session.
##### stopKeySync()
Stop Key Synchronization for the current session.
##### startKeyserverLookup()
Start a global thread for Keyserver Lookup. This thread handles all keyserver communication for all sessions.
##### stopKeyserverLookup()
Stop the global thread for Keyserver Lookup.
##### encrypt_message(Message src, StringList extra_keys, Message⇑ dst, PEP_enc_format enc_format, Integer flags)
encrypt message in memory
@ -749,12 +743,5 @@ JSON Adapter version etc.
##### version()
Returns a codename for the current JSON Server Adapter's version.
##### getGpgEnvironment()
Returns a struct holding 3 members
* gnupg_path
* gnupg_home environment variable, if set
* gpg_agent_info environment variable, if set.
##### shutdown()
shutdown the JSON Adapter

+ 0
- 82
server/mini-adapter-impl.cc View File

@ -2,38 +2,13 @@
#include "json-adapter.hh"
#include <thread>
#include <pEp/keymanagement.h>
#include <pEp/call_with_lock.hh>
#include <pEp/status_to_string.hh> // from libpEpAdapter.
#include <pEp/locked_queue.hh>
#include <pEp/Adapter.hh>
#include <pEp/callback_dispatcher.hh>
namespace pEp {
namespace mini {
typedef std::unique_ptr<std::thread> ThreadPtr;
// keyserver lookup
utility::locked_queue< pEp_identity*, &free_identity> keyserver_lookup_queue;
PEP_SESSION keyserver_lookup_session = nullptr; // FIXME: what if another adapter started it already?
ThreadPtr keyserver_lookup_thread;
int injectIdentity(pEp_identity* idy)
{
keyserver_lookup_queue.push_back(idy);
return 0;
}
pEp_identity* retrieveNextIdentity(void* /*userdata*/)
{
return keyserver_lookup_queue.pop_front();
}
struct dummy_t{};
dummy_t dummy{};
void startSync()
{
pEp::callback_dispatcher.start_sync();
@ -46,63 +21,6 @@ void stopSync()
}
void startKeyserverLookup()
{
if(keyserver_lookup_session)
throw std::runtime_error("KeyserverLookup already started.");
PEP_STATUS status = pEp::call_with_lock(&init, &keyserver_lookup_session, pEp::CallbackDispatcher::messageToSend, ::pEp::Adapter::_inject_sync_event, pEp::Adapter::_ensure_passphrase);
if(status != PEP_STATUS_OK || keyserver_lookup_session==nullptr)
{
throw std::runtime_error("Cannot create keyserver lookup session! status: " + ::pEp::status_to_string(status));
}
keyserver_lookup_queue.clear();
status = register_examine_function(keyserver_lookup_session,
examineIdentity,
&keyserver_lookup_session // nullptr is not accepted, so any dummy ptr is used here
);
if (status != PEP_STATUS_OK)
throw std::runtime_error("Cannot register keyserver lookup callbacks! status: " + ::pEp::status_to_string(status));
keyserver_lookup_thread.reset( new std::thread( &keyserverLookupThreadRoutine, &keyserver_lookup_session /* just a dummy */ ) );
}
void stopKeyserverLookup()
{
// No keyserver lookup session active
if(keyserver_lookup_session == nullptr)
return;
keyserver_lookup_queue.push_front(NULL);
keyserver_lookup_thread->join();
// there is no unregister_examine_callback() function. hum...
keyserver_lookup_queue.clear();
pEp::call_with_lock(&release, keyserver_lookup_session);
keyserver_lookup_session = nullptr;
}
int examineIdentity(pEp_identity* idy, void* obj)
{
// JsonAdapter* ja = static_cast<JsonAdapter*>(obj);
return injectIdentity(idy);
}
void* keyserverLookupThreadRoutine(void* arg)
{
PEP_STATUS status = do_keymanagement(
&retrieveNextIdentity,
arg); // does the whole work
keyserver_lookup_queue.clear();
return (void*) status;
}
Adapter& Adapter::createInstance()
{
return dynamic_cast<Adapter&>(JsonAdapter::createInstance( new Adapter() ));


+ 0
- 14
server/mini-adapter-impl.hh View File

@ -1,30 +1,16 @@
#ifndef MINI_ADAPTER_IMPL_HH
#define MINI_ADAPTER_IMPL_HH
#include <pEp/keymanagement.h>
#include <pEp/sync_api.h>
#include "json-adapter.hh"
#include <pEp/passphrase_cache.hh>
#include <pEp/Adapter.hh>
namespace pEp{
namespace mini {
int injectIdentity(pEp_identity* idy);
pEp_identity* retrieveNextIdentity( void* /*management*/);
void startSync();
void stopSync();
void startKeyserverLookup();
void stopKeyserverLookup();
int examineIdentity(pEp_identity* idy, void* obj);
void* keyserverLookupThreadRoutine(void* arg);
class Adapter : public JsonAdapter
{
public:


Loading…
Cancel
Save