diff --git a/src/pEp/_pybind/pEpModule.cc b/src/pEp/_pybind/pEpModule.cc index de0b79d..c6f996d 100644 --- a/src/pEp/_pybind/pEpModule.cc +++ b/src/pEp/_pybind/pEpModule.cc @@ -1,14 +1,88 @@ #include #include +#include +#include "../_pEp/adapter_main.hh" using namespace std; -string testfunc() { - return "fsdfg"; + +namespace pyadpt = pEp::PythonAdapter; +namespace alib = pEp::Adapter; +namespace py = pybind11; + +struct _datta { + int great = 3; + int shit = 1; +}; + +typedef _datta datta; +typedef datta *DATTA; +// +datta ms; + +DATTA dataPointer() { + return &ms; +} + +struct _pEpSession *getSession() { + return alib::session.get(); +} + +void *getSessionHandle() { + void *handle = static_cast(alib::session()); + return handle; } PYBIND11_MODULE(_pybind, m) { m.doc() = "pybind11 example plugin"; // optional module docstring - m.def("add", &testfunc, "A function which adds two numbers"); + + m.def("testfunc", &pyadpt::testfunc, "A function which adds two numbers"); + + py::class_(m, "datta").def(py::init<>()); + m.def("dataPointer", &dataPointer, py::return_value_policy::reference); + + // PEP_SESSION + m.def("get_handle", &getSessionHandle); + + + // DYNAMIC_API void set_debug_color(PEP_SESSION session, int ansi_color); + m.def("set_debug_color", (void (*)(void *, int))&::set_debug_color); + + // typedef struct _pEp_identity { + // char *address; // C string with address UTF-8 encoded + // char *fpr; // C string with fingerprint UTF-8 encoded + // char *user_id; // C string with user ID UTF-8 encoded + // // user_id MIGHT be set to "pEp_own_userId" + // // (use PEP_OWN_USERID preprocessor define) + // // if this is own user's identity. + // // But it is not REQUIRED to be. + // char *username; // C string with user name UTF-8 encoded + // PEP_comm_type comm_type; // type of communication with this ID + // char lang[3]; // language of conversation + // // ISO 639-1 ALPHA-2, last byte is 0 + // bool me; // if this is the local user herself/himself + // unsigned int major_ver; // highest version of pEp message received, if any + // unsigned int minor_ver; // highest version of pEp message received, if any + // PEP_enc_format enc_format; // Last specified format we encrypted to for this identity + // identity_flags_t flags; // identity_flag1 | identity_flag2 | ... + // } pEp_identity; + + py::class_(m, "pEp_identity") + .def_readwrite("address", &::pEp_identity::address) + .def_readwrite("fpr", &::pEp_identity::fpr) + .def_readwrite("user_id", &::pEp_identity::user_id) + .def_readwrite("username", &::pEp_identity::username); + + + // DYNAMIC_API pEp_identity *new_identity( + // const char *address, const char *fpr, const char *user_id, + // const char *username + // ); + m.def("new_identity", (pEp_identity *(*)(const char *address, const char *fpr, const char *user_id, const char *username))&::new_identity, py::return_value_policy::reference); + + // DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity); + m.def("myself", (PEP_STATUS(*)(void *, pEp_identity *))&myself); + } +