Browse Source

Added Logging of every c/c++ function call (in DEBUG build only)

resolved possible var name ambiguity
corrected some formatting inconsistencies
JNI-92
heck 5 years ago
parent
commit
25a07dcfde
  1. 15
      src/basic_api.cc
  2. 200
      src/foundation_pEp_jniadapter_AbstractEngine.cc
  3. 5
      src/foundation_pEp_jniadapter__Blob.cc
  4. 2
      src/gen_cpp_Engine.ysl2
  5. 29
      src/gen_cpp_Message.ysl2
  6. 9
      src/identity_api.cc

15
src/basic_api.cc

@ -20,6 +20,7 @@ JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter_Engine_trustwords(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
char *words; char *words;
size_t wsize; size_t wsize;
@ -57,6 +58,7 @@ JNIEXPORT jobject JNICALL Java_foundation_pEp_jniadapter_Engine_myself(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
PEP_STATUS status = ::myself(session(), _ident); PEP_STATUS status = ::myself(session(), _ident);
@ -75,6 +77,7 @@ JNIEXPORT jobject JNICALL Java_foundation_pEp_jniadapter_Engine_updateIdentity(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
::update_identity(session(), _ident); ::update_identity(session(), _ident);
@ -89,6 +92,7 @@ JNIEXPORT jobject JNICALL Java_foundation_pEp_jniadapter_Engine_setOwnKey(
jbyteArray fpr jbyteArray fpr
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
char *_fpr = to_string(env, fpr); char *_fpr = to_string(env, fpr);
@ -109,6 +113,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_keyMistrusted(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) { if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -132,6 +137,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_keyResetTrust(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) { if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -155,6 +161,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_trustPersonalKey(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) { if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -178,6 +185,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_trustOwnKey(
jobject ident jobject ident
) )
{ {
pEpLog("called");
pEp_identity *_ident = to_identity(env, ident); pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) { if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -194,6 +202,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_importKey(
jbyteArray key jbyteArray key
) )
{ {
pEpLog("called");
size_t _size = (size_t) env->GetArrayLength(key); size_t _size = (size_t) env->GetArrayLength(key);
char *_key = (char *) env->GetByteArrayElements(key, NULL); char *_key = (char *) env->GetByteArrayElements(key, NULL);
@ -217,6 +226,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_config_1passive_1mo
jboolean enable jboolean enable
) )
{ {
pEpLog("called");
::config_passive_mode(session(), (bool)enable); ::config_passive_mode(session(), (bool)enable);
} }
@ -227,6 +237,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_config_1unencrypted
jboolean enable jboolean enable
) )
{ {
pEpLog("called");
::config_unencrypted_subject(session(), (bool)enable); ::config_unencrypted_subject(session(), (bool)enable);
} }
@ -236,6 +247,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_blacklist_1add(
jbyteArray fpr jbyteArray fpr
) )
{ {
pEpLog("called");
char *_fpr = to_string(env, fpr); char *_fpr = to_string(env, fpr);
if(_fpr == NULL){ if(_fpr == NULL){
@ -257,6 +269,7 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine_blacklist_1delete(
jbyteArray fpr jbyteArray fpr
) )
{ {
pEpLog("called");
char *_fpr = to_string(env, fpr); char *_fpr = to_string(env, fpr);
if(_fpr == NULL){ if(_fpr == NULL){
@ -278,6 +291,7 @@ JNIEXPORT jboolean JNICALL Java_foundation_pEp_jniadapter_Engine_blacklist_1is_1
jbyteArray fpr jbyteArray fpr
) )
{ {
pEpLog("called");
char *_fpr = to_string(env, fpr); char *_fpr = to_string(env, fpr);
bool _listed = 0; bool _listed = 0;
@ -302,6 +316,7 @@ JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter_Engine_getCrashdumpL
jint maxlines jint maxlines
) )
{ {
pEpLog("called");
int _maxlines = (int) maxlines; int _maxlines = (int) maxlines;
char *_logdata; char *_logdata;

200
src/foundation_pEp_jniadapter_AbstractEngine.cc

@ -1,17 +1,4 @@
#include "foundation_pEp_jniadapter_AbstractEngine.h" #include "foundation_pEp_jniadapter_AbstractEngine.h"
#ifndef NDEBUG
#include <iostream>
auto& debug_log = std::cerr;
#else
// the compiler should optimize this away
static struct _debug_log {
_debug_log& operator<<(const char*) { return *this; }
_debug_log& operator<<(int) { return *this; }
_debug_log& operator<<(double) { return *this; }
} debug_log;
#endif
#include <stdexcept> #include <stdexcept>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
@ -20,38 +7,39 @@ static struct _debug_log {
#include <pEp/message_api.h> #include <pEp/message_api.h>
#include <pEp/sync_api.h> #include <pEp/sync_api.h>
#include <pEp/Adapter.hh> #include <pEp/Adapter.hh>
#include <pEp/utils.hh>
#include "throw_pEp_exception.hh" #include "throw_pEp_exception.hh"
#include "jniutils.hh" #include "jniutils.hh"
namespace pEp { namespace pEp {
using namespace pEp::JNIAdapter; using namespace pEp::JNIAdapter;
using namespace utility; using namespace utility; // for libpEpAdapter locked queue impl. TODO:rename
bool first = true; bool first = true;
JavaVM *jvm= nullptr; JavaVM *jvm= nullptr;
std::mutex mutex_obj; std::mutex mutex_obj;
jfieldID field_value = nullptr; jfieldID field_value = nullptr;
jmethodID messageConstructorMethodID = nullptr; jmethodID messageConstructorMethodID = nullptr;
jmethodID messageToSendMethodID = nullptr; jmethodID messageToSendMethodID = nullptr;
jmethodID notifyHandShakeMethodID = nullptr; jmethodID notifyHandShakeMethodID = nullptr;
jmethodID needsFastPollMethodID = nullptr; jmethodID needsFastPollMethodID = nullptr;
jmethodID method_values = nullptr; jmethodID method_values = nullptr;
jobject obj = nullptr; jobject obj = nullptr;
jclass messageClass = nullptr; jclass messageClass = nullptr;
jclass identityClass = nullptr;; jclass identityClass = nullptr;;
jclass signalClass = nullptr; jclass signalClass = nullptr;
jclass engineClass = nullptr; jclass engineClass = nullptr;
class JNISync { class JNISync {
public: public:
JNIEnv * env() JNIEnv * env()
{ {
pEpLog("called");
JNIEnv *thread_env = nullptr; JNIEnv *thread_env = nullptr;
int status = jvm->GetEnv((void**)&thread_env, JNI_VERSION_1_6); int status = jvm->GetEnv((void**)&thread_env, JNI_VERSION_1_6);
if (status < 0) { if (status < 0) {
@ -67,16 +55,19 @@ namespace pEp {
void onSyncStartup() void onSyncStartup()
{ {
pEpLog("called");
env(); env();
} }
void onSyncShutdown() void onSyncShutdown()
{ {
pEpLog("called");
jvm->DetachCurrentThread(); jvm->DetachCurrentThread();
} }
} o; } o;
void jni_init() { void jni_init() {
pEpLog("called");
JNIEnv *_env = o.env(); JNIEnv *_env = o.env();
messageClass = reinterpret_cast<jclass>( messageClass = reinterpret_cast<jclass>(
@ -104,13 +95,14 @@ namespace pEp {
method_values = o.env()->GetStaticMethodID(signalClass, "values", method_values = o.env()->GetStaticMethodID(signalClass, "values",
"()[Lfoundation/pEp/jniadapter/SyncHandshakeSignal;"); "()[Lfoundation/pEp/jniadapter/SyncHandshakeSignal;");
field_value = o.env()->GetFieldID(signalClass, "value", "I"); field_value = o.env()->GetFieldID(signalClass, "value", "I");
} }
PEP_STATUS messageToSend(message *msg) PEP_STATUS messageToSend(message *msg)
{ {
pEpLog("called");
std::lock_guard<std::mutex> l(mutex_obj); std::lock_guard<std::mutex> l(mutex_obj);
debug_log << "\n############### messageToSend() called\n"; pEpLog("############### messageToSend() called");
jobject msg_ = nullptr; jobject msg_ = nullptr;
assert(messageClass && messageConstructorMethodID && obj && messageToSendMethodID); assert(messageClass && messageConstructorMethodID && obj && messageToSendMethodID);
@ -126,13 +118,14 @@ namespace pEp {
return status; return status;
} }
PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal) PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal)
{ {
pEpLog("called");
std::lock_guard<std::mutex> l(mutex_obj); std::lock_guard<std::mutex> l(mutex_obj);
debug_log << "\n############### notifyHandshake() called\n"; pEpLog("############### notifyHandshake() called");
jobject me_ = nullptr; jobject me_ = nullptr;
jobject partner_ = nullptr; jobject partner_ = nullptr;
@ -174,18 +167,20 @@ namespace pEp {
} }
return status; return status;
} }
} }
extern "C" { extern "C" {
using namespace pEp; using namespace pEp;
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_init( JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_init(
JNIEnv *env, JNIEnv *env,
jobject me jobject me
) )
{ {
pEpLog("called");
if (first) { if (first) {
pEpLog("first Engine instance");
first = false; first = false;
env->GetJavaVM(&jvm); env->GetJavaVM(&jvm);
jni_init(); jni_init();
@ -193,35 +188,46 @@ extern "C" {
Adapter::_messageToSend = messageToSend; Adapter::_messageToSend = messageToSend;
} }
Adapter::session(); Adapter::session();
} }
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_release( JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_release(
JNIEnv *env, JNIEnv *env,
jobject me jobject me
) )
{ {
pEpLog("called");
Adapter::session(pEp::Adapter::release); Adapter::session(pEp::Adapter::release);
} }
JNIEXPORT jstring JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_getVersion(JNIEnv *env, jobject) JNIEXPORT jstring JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_getVersion(
{ JNIEnv *env,
jobject
)
{
pEpLog("called");
return env->NewStringUTF(::get_engine_version()); return env->NewStringUTF(::get_engine_version());
} }
JNIEXPORT jstring JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_getProtocolVersion(JNIEnv *env, jobject) JNIEXPORT jstring JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_getProtocolVersion(
{ JNIEnv *env,
jobject
)
{
pEpLog("called");
return env->NewStringUTF(::get_protocol_version()); return env->NewStringUTF(::get_protocol_version());
} }
int examine_identity(pEp_identity *ident, void *arg) int examine_identity(pEp_identity *ident, void *arg)
{ {
pEpLog("called");
locked_queue< pEp_identity * > *queue = (locked_queue< pEp_identity * > *) arg; locked_queue< pEp_identity * > *queue = (locked_queue< pEp_identity * > *) arg;
queue->push_back(identity_dup(ident)); queue->push_back(identity_dup(ident));
return 0; return 0;
} }
pEp_identity *retrieve_next_identity(void *arg) pEp_identity *retrieve_next_identity(void *arg)
{ {
pEpLog("called");
locked_queue< pEp_identity * > *queue = (locked_queue< pEp_identity * > *) arg; locked_queue< pEp_identity * > *queue = (locked_queue< pEp_identity * > *) arg;
while (!queue->size()) while (!queue->size())
@ -230,10 +236,11 @@ extern "C" {
pEp_identity *ident = queue->front(); pEp_identity *ident = queue->front();
queue->pop_front(); queue->pop_front();
return ident; return ident;
} }
static void *keyserver_thread_routine(void *arg) static void *keyserver_thread_routine(void *arg)
{ {
pEpLog("called");
PEP_STATUS status = do_keymanagement(retrieve_next_identity, arg); PEP_STATUS status = do_keymanagement(retrieve_next_identity, arg);
locked_queue< pEp_identity * > *queue = (locked_queue< pEp_identity * > *) arg; locked_queue< pEp_identity * > *queue = (locked_queue< pEp_identity * > *) arg;
@ -245,13 +252,14 @@ extern "C" {
delete queue; delete queue;
return (void *) status; return (void *) status;
} }
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_startKeyserverLookup( JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_startKeyserverLookup(
JNIEnv *env, JNIEnv *env,
jobject obj jobject me
) )
{ {
pEpLog("called");
pthread_t *thread = nullptr; pthread_t *thread = nullptr;
locked_queue< pEp_identity * > *queue = nullptr; locked_queue< pEp_identity * > *queue = nullptr;
@ -267,27 +275,28 @@ extern "C" {
return; return;
} }
thread = (pthread_t *) env->GetLongField(obj, thread_handle); thread = (pthread_t *) env->GetLongField(me, thread_handle);
if (thread) if (thread)
return; return;
thread = (pthread_t *) calloc(1, sizeof(pthread_t)); thread = (pthread_t *) calloc(1, sizeof(pthread_t));
assert(thread); assert(thread);
env->SetLongField(obj, thread_handle, (jlong) thread); env->SetLongField(me, thread_handle, (jlong) thread);
queue = new locked_queue< pEp_identity * >(); queue = new locked_queue< pEp_identity * >();
env->SetLongField(obj, queue_handle, (jlong) queue); env->SetLongField(me, queue_handle, (jlong) queue);
register_examine_function(Adapter::session(), examine_identity, (void *) queue); register_examine_function(Adapter::session(), examine_identity, (void *) queue);
pthread_create(thread, nullptr, keyserver_thread_routine, (void *) queue); pthread_create(thread, nullptr, keyserver_thread_routine, (void *) queue);
} }
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_stopKeyserverLookup( JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_stopKeyserverLookup(
JNIEnv *env, JNIEnv *env,
jobject obj jobject me
) )
{ {
pEpLog("called");
pthread_t *thread = nullptr; pthread_t *thread = nullptr;
locked_queue< pEp_identity * > *queue = nullptr; locked_queue< pEp_identity * > *queue = nullptr;
@ -303,28 +312,29 @@ extern "C" {
return; return;
} }
thread = (pthread_t *) env->GetLongField(obj, thread_handle); thread = (pthread_t *) env->GetLongField(me, thread_handle);
if (!thread) if (!thread)
return; return;
queue = (locked_queue< pEp_identity * > *) env->GetLongField(obj, queue_handle); queue = (locked_queue< pEp_identity * > *) env->GetLongField(me, queue_handle);
env->SetLongField(obj, queue_handle, (jlong) 0); env->SetLongField(me, queue_handle, (jlong) 0);
env->SetLongField(obj, thread_handle, (jlong) 0); env->SetLongField(me, thread_handle, (jlong) 0);
register_examine_function(Adapter::session(), nullptr, nullptr); register_examine_function(Adapter::session(), nullptr, nullptr);
queue->push_front(nullptr); queue->push_front(nullptr);
pthread_join(*thread, nullptr); pthread_join(*thread, nullptr);
free(thread); free(thread);
} }
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_startSync( JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_startSync(
JNIEnv *env, JNIEnv *env,
jobject obj jobject me
) )
{ {
debug_log << "######## starting sync\n"; pEpLog("called");
pEpLog("######## starting sync");
try { try {
Adapter::startup<JNISync>(messageToSend, notifyHandshake, &o, &JNISync::onSyncStartup, &JNISync::onSyncShutdown); Adapter::startup<JNISync>(messageToSend, notifyHandshake, &o, &JNISync::onSyncStartup, &JNISync::onSyncShutdown);
} }
@ -332,21 +342,25 @@ extern "C" {
throw_pEp_Exception(env, ex.status); throw_pEp_Exception(env, ex.status);
return; return;
} }
} }
JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_stopSync( JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_stopSync(
JNIEnv *env, JNIEnv *env,
jobject obj jobject me
) )
{ {
pEpLog("called");
Adapter::shutdown(); Adapter::shutdown();
} }
JNIEXPORT jboolean JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_isSyncRunning JNIEXPORT jboolean JNICALL Java_foundation_pEp_jniadapter_AbstractEngine_isSyncRunning(
(JNIEnv *, jobject) JNIEnv *env,
{ jobject me
)
{
pEpLog("called");
return (jboolean) Adapter::is_sync_running(); return (jboolean) Adapter::is_sync_running();
} }
} // extern "C" } // extern "C"

5
src/foundation_pEp_jniadapter__Blob.cc

@ -1,6 +1,7 @@
#include <pEp/bloblist.h> #include <pEp/bloblist.h>
#include <pEp/sync_codec.h> #include <pEp/sync_codec.h>
#include <pEp/distribution_codec.h> #include <pEp/distribution_codec.h>
#include <pEp/utils.hh>
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
@ -32,9 +33,9 @@ extern "C" {
using namespace std; using namespace std;
using namespace pEp::JNIAdapter; using namespace pEp::JNIAdapter;
JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter__1Blob__1dataToXER JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter__1Blob__1dataToXER(JNIEnv *env, jobject obj)
(JNIEnv *env, jobject obj)
{ {
pEpLog("called");
bloblist_t *b = to_blob(env, obj); bloblist_t *b = to_blob(env, obj);
char *out = nullptr; char *out = nullptr;

2
src/gen_cpp_Engine.ysl2

@ -15,6 +15,7 @@ tstylesheet {
#include <pEp/openpgp_compat.h> #include <pEp/openpgp_compat.h>
#include <pEp/key_reset.h> #include <pEp/key_reset.h>
#include <pEp/Adapter.hh> #include <pEp/Adapter.hh>
#include <pEp/utils.hh>
#include "foundation_pEp_jniadapter_«@name».h" #include "foundation_pEp_jniadapter_«@name».h"
#include "throw_pEp_exception.hh" #include "throw_pEp_exception.hh"
#include "jniutils.hh" #include "jniutils.hh"
@ -49,6 +50,7 @@ tstylesheet {
jobject obj`apply "parm[in|inout]", mode=sig` jobject obj`apply "parm[in|inout]", mode=sig`
) )
{ {
pEpLog("called");
|| ||
apply "parm[in|inout]", mode=in; apply "parm[in|inout]", mode=in;

29
src/gen_cpp_Message.ysl2

@ -1,4 +1,5 @@
include yslt.yml2 include yslt.yml2
include yslt.yml2
tstylesheet { tstylesheet {
include ./textutils.ysl2 include ./textutils.ysl2
@ -18,6 +19,7 @@ tstylesheet {
#include <assert.h> #include <assert.h>
#include <pEp/«@name».h> #include <pEp/«@name».h>
#include <pEp/mime.h> #include <pEp/mime.h>
#include <pEp/utils.hh>
#include "jniutils.hh" #include "jniutils.hh"
#include "throw_pEp_exception.hh" #include "throw_pEp_exception.hh"
@ -47,8 +49,9 @@ tstylesheet {
using namespace pEp::JNIAdapter; using namespace pEp::JNIAdapter;
JNIEXPORT jlong JNICALL JNIEXPORT jlong JNICALL Java_foundation_pEp_jniadapter_«$jname»_init(JNIEnv *env, jobject obj)
Java_foundation_pEp_jniadapter_«$jname»_init(JNIEnv *env, jobject obj) { {
pEpLog("called");
::«@name» * _obj = ::new_«@name»(PEP_dir_incoming); ::«@name» * _obj = ::new_«@name»(PEP_dir_incoming);
if (!_obj) { if (!_obj) {
outOfMemory(env); outOfMemory(env);
@ -57,17 +60,18 @@ tstylesheet {
return (jlong) (int64_t) (intptr_t) _obj; return (jlong) (int64_t) (intptr_t) _obj;
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_«$jname»_release(JNIEnv *env, jobject obj, jlong value)
Java_foundation_pEp_jniadapter_«$jname»_release(JNIEnv *env, jobject obj, jlong value) { {
pEpLog("called");
if (value) { if (value) {
::«@name» *_obj = (::«@name» *) (intptr_t) (int64_t) value; ::«@name» *_obj = (::«@name» *) (intptr_t) (int64_t) value;
::free_«@name»(_obj); ::free_«@name»(_obj);
} }
} }
JNIEXPORT jlong JNICALL Java_foundation_pEp_jniadapter_«$jname»__1«$jname»( JNIEXPORT jlong JNICALL Java_foundation_pEp_jniadapter_«$jname»__1«$jname»(JNIEnv *env, jobject msg, jbyteArray mime_text)
JNIEnv *env, jobject msg, jbyteArray mime_text) { {
pEpLog("called");
char *_mime_text = to_string(env, mime_text); char *_mime_text = to_string(env, mime_text);
size_t _size = (size_t) env->GetArrayLength(mime_text); size_t _size = (size_t) env->GetArrayLength(mime_text);
@ -80,6 +84,7 @@ tstylesheet {
JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter_«$jname»__1encodeMIME(JNIEnv *env, jobject msg) JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter_«$jname»__1encodeMIME(JNIEnv *env, jobject msg)
{ {
pEpLog("called");
«@name» *_obj = «@name»_ptr(env, msg); «@name» *_obj = «@name»_ptr(env, msg);
char *mime_text = nullptr; char *mime_text = nullptr;
PEP_STATUS status = ::mime_encode_«@name»(_obj, false, &mime_text); PEP_STATUS status = ::mime_encode_«@name»(_obj, false, &mime_text);
@ -132,8 +137,9 @@ tstylesheet {
with "name", "concat('set', $jname)"; with "name", "concat('set', $jname)";
} }
|| ||
JNIEXPORT `call "jni_type" with "type", "name(.)"` JNICALL JNIEXPORT `call "jni_type" with "type", "name(.)"` JNICALL «$getname»(JNIEnv *env, jobject obj)
«$getname»(JNIEnv *env, jobject obj) { {
pEpLog("called");
«$name» *_obj = «$name»_ptr(env, obj); «$name» *_obj = «$name»_ptr(env, obj);
|| ||
choose { choose {
@ -145,8 +151,9 @@ tstylesheet {
|| ||
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL «$setname»(JNIEnv *env, jobject obj, `call "jni_type" with "type", "name(.)"` value)
«$setname»(JNIEnv *env, jobject obj, `call "jni_type" with "type", "name(.)"` value) { {
pEpLog("called");
«$name» *_obj = «$name»_ptr(env, obj); «$name» *_obj = «$name»_ptr(env, obj);
|| ||
choose { choose {

9
src/identity_api.cc

@ -1,14 +1,15 @@
#include <pEp/message_api.h> #include <pEp/message_api.h>
#include <pEp/utils.hh>
#include "jniutils.hh" #include "jniutils.hh"
extern "C" { extern "C" {
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL Java_foundation_pEp_jniadapter_Identity__1getRating(JNIEnv *env, jobject thiz, jint comm_type)
Java_foundation_pEp_jniadapter_Identity__1getRating(JNIEnv *env, jobject thiz, jint comm_type) { {
pEpLog("called");
return ::rating_from_comm_type((PEP_comm_type) comm_type); return ::rating_from_comm_type((PEP_comm_type) comm_type);
} }
} // extern "C" } // extern "C"

Loading…
Cancel
Save