somewhat cleaner
parent
0293edca01
commit
944fb89e41
38
Adapter.cc
38
Adapter.cc
|
@ -6,10 +6,26 @@
|
|||
#include <iomanip>
|
||||
#include <assert.h>
|
||||
|
||||
namespace pEp {
|
||||
namespace Adapter {
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
namespace pEp {
|
||||
void throw_status(PEP_STATUS status)
|
||||
{
|
||||
if (status == PEP_STATUS_OK)
|
||||
return;
|
||||
if (status >= 0x400 && status <= 0x4ff)
|
||||
return;
|
||||
if (status == PEP_OUT_OF_MEMORY)
|
||||
throw bad_alloc();
|
||||
if (status == PEP_ILLEGAL_VALUE)
|
||||
throw invalid_argument("illegal value");
|
||||
|
||||
stringstream build;
|
||||
build << setfill('0') << "p≡p 0x" << setw(4) << hex << status;
|
||||
throw runtime_error(build.str());
|
||||
}
|
||||
|
||||
namespace Adapter {
|
||||
static messageToSend_t _messageToSend = nullptr;
|
||||
static notifyHandshake_t _notifyHandshake = nullptr;
|
||||
static std::thread *_sync_thread = nullptr;
|
||||
|
@ -26,22 +42,6 @@ namespace pEp {
|
|||
return m;
|
||||
}
|
||||
|
||||
void throw_status(PEP_STATUS status)
|
||||
{
|
||||
if (status == PEP_STATUS_OK)
|
||||
return;
|
||||
if (status >= 0x400 && status <= 0x4ff)
|
||||
return;
|
||||
if (status == PEP_OUT_OF_MEMORY)
|
||||
throw bad_alloc();
|
||||
if (status == PEP_ILLEGAL_VALUE)
|
||||
throw invalid_argument("illegal value");
|
||||
|
||||
stringstream build;
|
||||
build << setfill('0') << "p≡p 0x" << setw(4) << hex << status;
|
||||
throw runtime_error(build.str());
|
||||
}
|
||||
|
||||
static int _inject_sync_event(SYNC_EVENT ev, void *management)
|
||||
{
|
||||
if (is_sync_thread(session())) {
|
||||
|
|
|
@ -11,8 +11,6 @@ namespace pEp {
|
|||
void throw_status(PEP_STATUS status);
|
||||
|
||||
namespace Adapter {
|
||||
void throw_status(PEP_STATUS status);
|
||||
|
||||
void startup(messageToSend_t messageToSend,
|
||||
notifyHandshake_t notifyHandshake, void *obj = nullptr);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ int main()
|
|||
assert(me);
|
||||
PEP_STATUS status = myself(session(), me);
|
||||
free_identity(me);
|
||||
throw_status(status);
|
||||
pEp::throw_status(status);
|
||||
|
||||
cout << "starting the adapter including sync\n";
|
||||
startup(messageToSend, notifyHandshake);
|
||||
|
|
Loading…
Reference in New Issue