Browse Source

somewhat cleaner

LPA-1
Volker Birk 7 years ago
parent
commit
944fb89e41
  1. 36
      Adapter.cc
  2. 2
      Adapter.hh
  3. 2
      test_adapter.cc

36
Adapter.cc

@ -6,26 +6,9 @@
#include <iomanip> #include <iomanip>
#include <assert.h> #include <assert.h>
namespace pEp {
namespace Adapter {
using namespace std; using namespace std;
static messageToSend_t _messageToSend = nullptr; namespace pEp {
static notifyHandshake_t _notifyHandshake = nullptr;
static std::thread *_sync_thread = nullptr;
static ::utility::locked_queue< SYNC_EVENT >& queue()
{
static ::utility::locked_queue< SYNC_EVENT > q;
return q;
}
static std::mutex& mtx()
{
static std::mutex m;
return m;
}
void throw_status(PEP_STATUS status) void throw_status(PEP_STATUS status)
{ {
if (status == PEP_STATUS_OK) if (status == PEP_STATUS_OK)
@ -42,6 +25,23 @@ namespace pEp {
throw runtime_error(build.str()); throw runtime_error(build.str());
} }
namespace Adapter {
static messageToSend_t _messageToSend = nullptr;
static notifyHandshake_t _notifyHandshake = nullptr;
static std::thread *_sync_thread = nullptr;
static ::utility::locked_queue< SYNC_EVENT >& queue()
{
static ::utility::locked_queue< SYNC_EVENT > q;
return q;
}
static std::mutex& mtx()
{
static std::mutex m;
return m;
}
static int _inject_sync_event(SYNC_EVENT ev, void *management) static int _inject_sync_event(SYNC_EVENT ev, void *management)
{ {
if (is_sync_thread(session())) { if (is_sync_thread(session())) {

2
Adapter.hh

@ -11,8 +11,6 @@ namespace pEp {
void throw_status(PEP_STATUS status); void throw_status(PEP_STATUS status);
namespace Adapter { namespace Adapter {
void throw_status(PEP_STATUS status);
void startup(messageToSend_t messageToSend, void startup(messageToSend_t messageToSend,
notifyHandshake_t notifyHandshake, void *obj = nullptr); notifyHandshake_t notifyHandshake, void *obj = nullptr);

2
test_adapter.cc

@ -29,7 +29,7 @@ int main()
assert(me); assert(me);
PEP_STATUS status = myself(session(), me); PEP_STATUS status = myself(session(), me);
free_identity(me); free_identity(me);
throw_status(status); pEp::throw_status(status);
cout << "starting the adapter including sync\n"; cout << "starting the adapter including sync\n";
startup(messageToSend, notifyHandshake); startup(messageToSend, notifyHandshake);

Loading…
Cancel
Save