Browse Source

adding more debugging functionality: sync_decode()

PYADPT-55
Volker Birk 9 years ago
parent
commit
06aa92d342
  1. 18
      src/message_api.cc
  2. 1
      src/message_api.hh
  3. 1
      src/pEpmodule.cc

18
src/message_api.cc

@ -1,6 +1,7 @@
#include "message_api.hh"
#include <pEp/pEpEngine.h>
#include <pEp/message_api.h>
#include <pEp/sync.h>
namespace pEp {
namespace PythonAdapter {
@ -65,6 +66,23 @@ namespace pEp {
{
::config_keep_sync_msg(session, enabled);
}
string sync_decode(object buffer)
{
Py_buffer src;
int result = PyObject_GetBuffer(buffer.ptr(), &src, PyBUF_CONTIG_RO);
if (result)
throw invalid_argument("need a contiguous buffer to read");
char *dst = NULL;
PEP_STATUS status = decode_sync_msg((char *) src.buf, src.len, &dst);
PyBuffer_Release(&src);
_throw_status(status);
string _dst(dst);
free(dst);
return _dst;
}
#endif
}
}

1
src/message_api.hh

@ -10,6 +10,7 @@ namespace pEp {
int _color(int rating);
#ifndef NDEBUG
void _config_keep_sync_msg(bool enabled);
string sync_decode(object buffer);
#endif
}
}

1
src/pEpmodule.cc

@ -206,6 +206,7 @@ BOOST_PYTHON_MODULE(pEp)
def("trustwords", &_trustwords, "calculate trustwords for two Identities");
#ifndef NDEBUG
def("config_keep_sync_msg", &_config_keep_sync_msg, "configure if sync messages are being kept or not");
def("sync_decode", &sync_decode, "decode sync message to XER/XML");
#endif
// key sync API

Loading…
Cancel
Save