Browse Source

init and release p≡p session

PYADPT-55
Volker Birk 9 years ago
parent
commit
b81c21aae6
  1. 20
      src/pEpmodule.cc
  2. 2
      src/pEpmodule.hh

20
src/pEpmodule.cc

@ -1,6 +1,7 @@
#include "pEpmodule.hh"
#include <boost/locale.hpp>
#include <string>
#include <sstream>
#include <pEp/pEpEngine.h>
#include "Identity.hh"
#include "Message.hh"
@ -15,6 +16,13 @@ namespace pEp {
+ PEP_VERSION + "\n";
return version;
}
PEP_SESSION session = NULL;
static void free_module(void *)
{
release(session);
}
}
}
@ -139,5 +147,17 @@ BOOST_PYTHON_MODULE(pEp)
(void(Message::*)(int))
(void(Message::*)(PEP_enc_format)) &Message::enc_format,
"0: unencrypted, 1: inline PGP, 2: S/MIME, 3: PGP/MIME, 4: p≡p format");
PyModuleDef * def = PyModule_GetDef(scope().ptr());
def->m_free = free_module;
PEP_STATUS status = ::init(&session);
if (status != PEP_STATUS_OK) {
stringstream ss;
ss << "init session failed with error " << status;
string s;
ss >> s;
throw runtime_error(s);
}
}

2
src/pEpmodule.hh

@ -1,12 +1,14 @@
#pragma once
#include <boost/python.hpp>
#include <pEp/pEpEngine.h>
namespace pEp {
namespace PythonAdapter {
using namespace std;
const char *version_string = "p≡p Python adapter version 0.1";
extern PEP_SESSION session;
}
}

Loading…
Cancel
Save