lime
Lime is a C++ library implementing Open Whisper System Signal protocol
Classes | Macros | Functions
lime_jni.cpp File Reference

Classes

struct  responseHolder
 Holds a stateful function pointer to be called to process the X3DH server response Encapsulate the function pointer in an object to pass its pointer to the java side as it cannot manage stateful function pointers. More...
 

Macros

#define METHOD(MethodPtr, name)   jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
 

Functions

static void jbyteArray2uin8_tVector (jni::JNIEnv &env, const jni::Array< jni::jbyte > &in, std::shared_ptr< std::vector< uint8_t >> &out)
 
static lime::PeerDeviceStatus j2cPeerDeviceStatus (jni::jint peerStatus)
 convert an int mapped java enumerated peerDevice Status into a c++ one More...
 
static jni::jint c2jPeerDeviceStatus (lime::PeerDeviceStatus peerStatus)
 convert a c++ enumerated peerDevice Status into a integer one More...
 
static jni::jint c2jCallbackReturn (lime::CallbackReturn status)
 convert a c++ enumerated CallbackReturn into a integer one More...
 
static lime::EncryptionPolicy j2cEncryptionPolicy (jni::jint encryptionPolicy)
 convert a int mapped java enumerated encryptionPolicy into a c++ one More...
 
static lime::CurveId j2cCurveId (jni::jint curveId)
 convert a int mapped java enumerated curveId into a c++ one More...
 
JNIEXPORT jint JNICALL JNI_OnLoad (JavaVM *vm, void *)
 

Detailed Description

Author
Johan Pascal

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

◆ METHOD

#define METHOD (   MethodPtr,
  name 
)    jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)

Function Documentation

◆ c2jCallbackReturn()

static jni::jint c2jCallbackReturn ( lime::CallbackReturn  status)
static

convert a c++ enumerated CallbackReturn into a integer one

mapping in java is : SUCCESS(0) FAIL(1)

Parameters
[in]statusthe c++ enumerated peer Device Status
Returns
the java enumerated peer device status (silently default to 1:FAIL)

◆ c2jPeerDeviceStatus()

static jni::jint c2jPeerDeviceStatus ( lime::PeerDeviceStatus  peerStatus)
static

convert a c++ enumerated peerDevice Status into a integer one

mapping in java is : UNTRUSTED(0) TRUSTED(1) UNSAFE(2) FAIL(3) UNKNOWN(4)

Parameters
[in]peerStatusthe c++ enumerated peer Device Status
Returns
the java enumerated peer device status (silently default to 4:UNKNOWN)

◆ j2cCurveId()

static lime::CurveId j2cCurveId ( jni::jint  curveId)
static

convert a int mapped java enumerated curveId into a c++ one

mapping is : C25519(1) C448(2)

Parameters
[in]curveIdThe java mapped integer to a curveId enum
Returns
the c++ enumerated curveId (silently default to unset)

◆ j2cEncryptionPolicy()

static lime::EncryptionPolicy j2cEncryptionPolicy ( jni::jint  encryptionPolicy)
static

convert a int mapped java enumerated encryptionPolicy into a c++ one

mapping is : DRMESSAGE(0) CIPHERMESSAGE(1) OPTIMIZEUPLOADSIZE(2) OPTIMIZEGLOBALBANDWIDTH(3)

Parameters
[in]encryptionPolicyThe java mapped integer to an encryption policy enum
Returns
the c++ enumerated encryption policy (silently default to optimizeUploadSize)

◆ j2cPeerDeviceStatus()

static lime::PeerDeviceStatus j2cPeerDeviceStatus ( jni::jint  peerStatus)
static

convert an int mapped java enumerated peerDevice Status into a c++ one

mapping is : UNTRUSTED(0) TRUSTED(1) UNSAFE(2) FAIL(3) UNKNOWN(4)

Parameters
[in]peerStatusThe java mapped integer to a curveId enum
Returns
the c++ enumerated peer device status (silently default to unknown)

◆ jbyteArray2uin8_tVector()

static void jbyteArray2uin8_tVector ( jni::JNIEnv &  env,
const jni::Array< jni::jbyte > &  in,
std::shared_ptr< std::vector< uint8_t >> &  out 
)
static

◆ JNI_OnLoad()

JNIEXPORT jint JNICALL JNI_OnLoad ( JavaVM *  vm,
void *   
)

< a unique pointer to the actual lime manager

< a global reference to the java postToX3DH object. TODO: unclear if EnvIgnoringDeleter is not a better fit here.

Constructor unlike the native lime manager constructor, this one get only one argument has cpp closure cannot be passed easily to java

Parameters
[in]db_accessthe database access path

process response from X3DH server This function is bind to a java PostToX3DH object process_response method It :

  • converts from jbytes(signed char) to unsigned char the response array
  • retrieves from the given back responseHolder pointer the closure pointer to callback the line lib and call it