aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src/main
diff options
context:
space:
mode:
authorylecollen <ylecollen@amdocs.com>2017-01-09 10:01:01 +0100
committerylecollen <ylecollen@amdocs.com>2017-01-09 10:01:01 +0100
commit03396102691409083143882ee1ed54e137f183d2 (patch)
tree3f00cc46e81d9539b45beed5562345fa887d8bf3 /java/android/OlmLibSdk/olm-sdk/src/main
parenteec8a50cafc75c025a98133520e8d8e9cf97e115 (diff)
Simplify the function declarations in olm_jni to avoid having to cast the getXXX methods
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java2
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp20
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp24
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni.h11
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni_helper.cpp41
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp40
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp10
7 files changed, 71 insertions, 77 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
index 3a78365..6737963 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
@@ -17,10 +17,8 @@
package org.matrix.olm;
-import android.text.TextUtils;
import android.util.Log;
-import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
index 53eace7..7441da4 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
@@ -60,7 +60,7 @@ JNIEXPORT void OLM_ACCOUNT_FUNC_DEF(releaseAccountJni)(JNIEnv *env, jobject thiz
{
LOGD("## releaseAccountJni(): IN");
- OlmAccount* accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz);
+ OlmAccount* accountPtr = getAccountInstanceId(env, thiz);
if (!accountPtr)
{
@@ -152,7 +152,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject
{
const char* errorMessage = NULL;
jbyteArray byteArrayRetValue = NULL;
- OlmAccount* accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz);
+ OlmAccount* accountPtr = getAccountInstanceId(env, thiz);
if (!accountPtr)
{
@@ -220,7 +220,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject
**/
JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(maxOneTimeKeysJni)(JNIEnv *env, jobject thiz)
{
- OlmAccount* accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz);
+ OlmAccount* accountPtr = getAccountInstanceId(env, thiz);
size_t maxKeys = -1;
if (!accountPtr)
@@ -244,7 +244,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(maxOneTimeKeysJni)(JNIEnv *env, jobject thi
JNIEXPORT void OLM_ACCOUNT_FUNC_DEF(generateOneTimeKeysJni)(JNIEnv *env, jobject thiz, jint aNumberOfKeys)
{
const char* errorMessage = NULL;
- OlmAccount *accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz);
+ OlmAccount *accountPtr = getAccountInstanceId(env, thiz);
if (!accountPtr)
{
@@ -304,7 +304,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(oneTimeKeysJni)(JNIEnv *env, jobject t
{
const char* errorMessage = NULL;
jbyteArray byteArrayRetValue = NULL;
- OlmAccount* accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz);
+ OlmAccount* accountPtr = getAccountInstanceId(env, thiz);
LOGD("## oneTimeKeysJni(): IN");
@@ -380,7 +380,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(removeOneTimeKeysJni)(JNIEnv *env, jobject t
LOGE("## removeOneTimeKeysJni(): failure - invalid session ptr");
errorMessage = "invalid session ptr";
}
- else if(!(accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz)))
+ else if(!(accountPtr = getAccountInstanceId(env, thiz)))
{
LOGE("## removeOneTimeKeysJni(): failure - invalid account ptr");
errorMessage = "invalid account ptr";
@@ -415,7 +415,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(removeOneTimeKeysJni)(JNIEnv *env, jobject t
JNIEXPORT void OLM_ACCOUNT_FUNC_DEF(markOneTimeKeysAsPublishedJni)(JNIEnv *env, jobject thiz)
{
const char* errorMessage = NULL;
- OlmAccount* accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz);
+ OlmAccount* accountPtr = getAccountInstanceId(env, thiz);
if (!accountPtr)
{
@@ -460,7 +460,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject t
LOGE("## signMessageJni(): failure - invalid aMessage param");
errorMessage = "invalid aMessage param";
}
- else if(!(accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz)))
+ else if (!(accountPtr = getAccountInstanceId(env, thiz)))
{
LOGE("## signMessageJni(): failure - invalid account ptr");
errorMessage = "invalid account ptr";
@@ -543,7 +543,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thi
LOGE(" ## serializeJni(): failure - invalid key");
errorMessage = "invalid key";
}
- else if (!(accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz)))
+ else if (!(accountPtr = getAccountInstanceId(env, thiz)))
{
LOGE(" ## serializeJni(): failure - invalid account ptr");
errorMessage = "invalid account ptr";
@@ -625,7 +625,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz
{
LOGE(" ## deserializeJni(): failure - serialized data");
}
- else if (!(accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz)))
+ else if (!(accountPtr = getAccountInstanceId(env, thiz)))
{
LOGE(" ## deserializeJni(): failure - account failure OOM");
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
index 315f607..dd3e0a9 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
@@ -26,11 +26,11 @@ using namespace AndroidOlmSdk;
*/
JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env, jobject thiz)
{
- OlmInboundGroupSession* sessionPtr = NULL;
+ OlmInboundGroupSession* sessionPtr = getInboundGroupSessionInstanceId(env,thiz);
LOGD("## releaseSessionJni(): InBound group session IN");
- if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## releaseSessionJni(): failure - invalid inbound group session instance");
}
@@ -88,13 +88,13 @@ JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *
JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer)
{
const char* errorMessage = NULL;
- OlmInboundGroupSession *sessionPtr = NULL;
+ OlmInboundGroupSession *sessionPtr = getInboundGroupSessionInstanceId(env, thiz);
jbyte* sessionKeyPtr = NULL;
size_t sessionResult;
LOGD("## initInboundGroupSessionJni(): inbound group session IN");
- if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## initInboundGroupSessionJni(): failure - invalid inbound group session instance");
errorMessage = "invalid inbound group session instance";
@@ -143,12 +143,12 @@ JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionJni)(JN
JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEnv *env, jobject thiz)
{
const char* errorMessage = NULL;
- OlmInboundGroupSession *sessionPtr = NULL;
+ OlmInboundGroupSession *sessionPtr = getInboundGroupSessionInstanceId(env, thiz);
jbyteArray returnValue = 0;
LOGD("## sessionIdentifierJni(): inbound group session IN");
- if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## sessionIdentifierJni(): failure - invalid inbound group session instance");
errorMessage = "invalid inbound group session instance";
@@ -202,14 +202,14 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEn
jbyteArray decryptedMsgBuffer = 0;
const char* errorMessage = NULL;
- OlmInboundGroupSession *sessionPtr = NULL;
+ OlmInboundGroupSession *sessionPtr = getInboundGroupSessionInstanceId(env, thiz);
jbyte *encryptedMsgPtr = NULL;
jclass indexObjJClass = 0;
jfieldID indexMsgFieldId;
LOGD("## decryptMessageJni(): inbound group session IN");
- if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## decryptMessageJni(): failure - invalid inbound group session ptr=NULL");
errorMessage = "invalid inbound group session ptr=NULL";
@@ -337,11 +337,11 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeJni)(JNIEnv *en
jbyteArray pickledDataRet = 0;
jbyte* keyPtr = NULL;
- OlmInboundGroupSession* sessionPtr = NULL;
+ OlmInboundGroupSession* sessionPtr = getInboundGroupSessionInstanceId(env, thiz);
LOGD("## inbound group session serializeJni(): IN");
- if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## serializeJni(): failure - invalid session ptr");
errorMessage = "invalid session ptr";
@@ -411,14 +411,14 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeJni)(JNIEnv *en
JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
- OlmInboundGroupSession* sessionPtr = NULL;
+ OlmInboundGroupSession* sessionPtr = getInboundGroupSessionInstanceId(env, thiz);
jstring errorMessageRetValue = 0;
jbyte* keyPtr = NULL;
jbyte* pickledPtr = NULL;
LOGD("## deserializeJni(): IN");
- if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## deserializeJni(): failure - session failure OOM");
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni.h
index 1c80388..73a529d 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni.h
@@ -68,11 +68,12 @@ extern "C" {
// internal helper functions
bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize);
-jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
-jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
-jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
-jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
-jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
+
+struct OlmSession* getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
+struct OlmAccount* getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
+struct OlmInboundGroupSession* getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
+struct OlmOutboundGroupSession* getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
+struct OlmUtility* getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
#ifdef __cplusplus
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni_helper.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni_helper.cpp
index 7146f4e..a1f5c59 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni_helper.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni_helper.cpp
@@ -111,8 +111,8 @@ bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize)
* Read the instance ID of the calling object.
* @param aJniEnv pointer pointing on the JNI function table
* @param aJavaObject reference to the object on which the method is invoked
-* @param aCallingClass java calling clas name
-* @return the instance ID if operation succeed, -1 if instance ID was not found.
+* @param aCallingClass java calling class name
+* @return the related instance ID
**/
jlong getInstanceId(JNIEnv* aJniEnv, jobject aJavaObject, const char *aCallingClass)
{
@@ -125,7 +125,7 @@ jlong getInstanceId(JNIEnv* aJniEnv, jobject aJavaObject, const char *aCallingCl
if (requiredClass && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass)))
{
- LOGE("## getAccountInstanceId() failure - invalid instance of");
+ LOGE("## getInstanceId() failure - invalid instance of");
}
else if ((loaderClass = aJniEnv->GetObjectClass(aJavaObject)))
{
@@ -162,58 +162,53 @@ jlong getInstanceId(JNIEnv* aJniEnv, jobject aJavaObject, const char *aCallingCl
* Read the account instance ID of the calling object.
* @param aJniEnv pointer pointing on the JNI function table
* @param aJavaObject reference to the object on which the method is invoked
-* @return the instance ID if operation succeed, -1 if instance ID was not found.
+* @return the related OlmAccount.
**/
-jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
+struct OlmAccount* getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{
- jlong instanceId = getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_ACCOUNT);
- return instanceId;
+ return (struct OlmAccount*)getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_ACCOUNT);
}
/**
* Read the session instance ID of the calling object (aJavaObject).<br>
* @param aJniEnv pointer pointing on the JNI function table
* @param aJavaObject reference to the object on which the method is invoked
-* @return the instance ID if read succeed, -1 otherwise.
+* @return the related OlmSession.
**/
-jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
+struct OlmSession* getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{
- jlong instanceId = getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_SESSION);
- return instanceId;
+ return (struct OlmSession*)getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_SESSION);
}
/**
* Read the inbound group session instance ID of the calling object (aJavaObject).<br>
* @param aJniEnv pointer pointing on the JNI function table
* @param aJavaObject reference to the object on which the method is invoked
-* @return the instance ID if read succeed, -1 otherwise.
+* @return the related OlmInboundGroupSession.
**/
-jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
+struct OlmInboundGroupSession* getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{
- jlong instanceId = getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_INBOUND_GROUP_SESSION);
- return instanceId;
+ return (struct OlmInboundGroupSession*)getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_INBOUND_GROUP_SESSION);
}
/**
* Read the outbound group session instance ID of the calling object (aJavaObject).<br>
* @param aJniEnv pointer pointing on the JNI function table
* @param aJavaObject reference to the object on which the method is invoked
-* @return the instance ID if read succeed, -1 otherwise.
+* @return the related OlmOutboundGroupSession
**/
-jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
+struct OlmOutboundGroupSession* getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{
- jlong instanceId = getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_OUTBOUND_GROUP_SESSION);
- return instanceId;
+ return (struct OlmOutboundGroupSession*)getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_OUTBOUND_GROUP_SESSION);
}
/**
* Read the utility instance ID of the calling object (aJavaObject).<br>
* @param aJniEnv pointer pointing on the JNI function table
* @param aJavaObject reference to the object on which the method is invoked
-* @return the instance ID if read succeed, -1 otherwise.
+* @return the related OlmUtility
**/
-jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
+struct OlmUtility* getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{
- jlong instanceId = getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_UTILITY);
- return instanceId;
+ return (struct OlmUtility*)getInstanceId(aJniEnv, aJavaObject, CLASS_OLM_UTILITY);
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp
index 7cde2cd..d1459ae 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp
@@ -55,7 +55,7 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *env, jobject t
JNIEXPORT void OLM_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env, jobject thiz)
{
LOGD("## releaseSessionJni(): IN");
- OlmSession* sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz);
+ OlmSession* sessionPtr = getSessionInstanceId(env, thiz);
if (!sessionPtr)
{
@@ -108,11 +108,11 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(initNewSessionJni)(JNIEnv *env, jobject thi
**/
JNIEXPORT void OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aTheirOneTimeKeyBuffer)
{
+ OlmSession* sessionPtr = getSessionInstanceId(env, thiz);
const char* errorMessage = NULL;
- OlmSession* sessionPtr = NULL;
OlmAccount* accountPtr = NULL;
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## initOutboundSessionJni(): failure - invalid Session ptr=NULL");
errorMessage = "invalid Session ptr=NULL";
@@ -215,11 +215,11 @@ JNIEXPORT void OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
JNIEXPORT void OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aOneTimeKeyMsgBuffer)
{
const char* errorMessage = NULL;
- OlmSession *sessionPtr = NULL;
+ OlmSession *sessionPtr = getSessionInstanceId(env,thiz);
OlmAccount *accountPtr = NULL;
size_t sessionResult;
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## initInboundSessionJni(): failure - invalid Session ptr=NULL");
errorMessage = "invalid Session ptr=NULL";
@@ -282,13 +282,13 @@ JNIEXPORT void OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
{
const char* errorMessage = NULL;
- OlmSession *sessionPtr = NULL;
+ OlmSession *sessionPtr = getSessionInstanceId(env, thiz);
OlmAccount *accountPtr = NULL;
jbyte *messagePtr = NULL;
jbyte *theirIdentityKeyPtr = NULL;
size_t sessionResult;
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - invalid Session ptr=NULL");
errorMessage = "invalid Session ptr=NULL";
@@ -363,10 +363,10 @@ JNIEXPORT void OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
- OlmSession *sessionPtr = NULL;
+ OlmSession *sessionPtr = getSessionInstanceId(env, thiz);
jbyte *messagePtr = NULL;
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## matchesInboundSessionJni(): failure - invalid Session ptr=NULL");
}
@@ -415,11 +415,11 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobje
JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
- OlmSession *sessionPtr = NULL;
+ OlmSession *sessionPtr = getSessionInstanceId(env, thiz);
jbyte *messagePtr = NULL;
jbyte *theirIdentityKeyPtr = NULL;
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid Session ptr=NULL");
}
@@ -482,7 +482,7 @@ JNIEXPORT void OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
{
const char* errorMessage = NULL;
- OlmSession *sessionPtr = NULL;
+ OlmSession *sessionPtr = getSessionInstanceId(env, thiz);
jbyte *clearMsgPtr = NULL;
jclass encryptedMsgJClass = 0;
jfieldID encryptedMsgFieldId;
@@ -490,7 +490,7 @@ JNIEXPORT void OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
LOGD("## encryptMessageJni(): IN ");
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## encryptMessageJni(): failure - invalid Session ptr=NULL");
errorMessage = "invalid Session ptr=NULL";
@@ -627,14 +627,14 @@ JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobjec
jfieldID encryptedMsgFieldId;
jfieldID typeMsgFieldId;
// ptrs
- OlmSession *sessionPtr = NULL;
+ OlmSession *sessionPtr = getSessionInstanceId(env, thiz);
const char *encryptedMsgPtr = NULL; // <= obtained from encryptedMsgJstring
uint8_t *plainTextMsgPtr = NULL;
char *tempEncryptedPtr = NULL;
LOGD("## decryptMessageJni(): IN - OlmSession");
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE("## decryptMessageJni(): failure - invalid Session ptr=NULL");
errorMessage = "invalid Session ptr=NULL";
@@ -759,7 +759,7 @@ JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env,
LOGD("## getSessionIdentifierJni(): IN ");
- OlmSession *sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz);
+ OlmSession *sessionPtr = getSessionInstanceId(env, thiz);
if (!sessionPtr)
{
@@ -823,11 +823,11 @@ JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thi
jbyteArray returnValue = 0;
jbyte* keyPtr = NULL;
- OlmSession* sessionPtr = NULL;
+ OlmSession* sessionPtr = getSessionInstanceId(env, thiz);
LOGD("## serializeJni(): IN");
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## serializeJni(): failure - invalid session ptr");
errorMessage = "invalid session ptr";
@@ -897,14 +897,14 @@ JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thi
JNIEXPORT jstring OLM_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
- OlmSession* sessionPtr = NULL;
+ OlmSession* sessionPtr = getSessionInstanceId(env, thiz);
jstring errorMessageRetValue = 0;
jbyte* keyPtr = NULL;
jbyte* pickledPtr = NULL;
LOGD("## deserializeJni(): IN");
- if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
+ if (!sessionPtr)
{
LOGE(" ## deserializeJni(): failure - session failure OOM");
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
index f4a0c80..c4e6811 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
@@ -59,7 +59,7 @@ JNIEXPORT jlong OLM_UTILITY_FUNC_DEF(initUtilityJni)(JNIEnv *env, jobject thiz)
JNIEXPORT void OLM_UTILITY_FUNC_DEF(releaseUtilityJni)(JNIEnv *env, jobject thiz)
{
- OlmUtility* utilityPtr = (OlmUtility*)getUtilityInstanceId(env,thiz);
+ OlmUtility* utilityPtr = getUtilityInstanceId(env, thiz);
LOGD("## releaseUtilityJni(): IN");
@@ -88,14 +88,14 @@ JNIEXPORT void OLM_UTILITY_FUNC_DEF(releaseUtilityJni)(JNIEnv *env, jobject thiz
JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jbyteArray aSignatureBuffer, jbyteArray aKeyBuffer, jbyteArray aMessageBuffer)
{
jstring errorMessageRetValue = 0;
- OlmUtility* utilityPtr = NULL;
+ OlmUtility* utilityPtr = getUtilityInstanceId(env, thiz);
jbyte* signaturePtr = NULL;
jbyte* keyPtr = NULL;
jbyte* messagePtr = NULL;
LOGD("## verifyEd25519SignatureJni(): IN");
- if (!(utilityPtr = (OlmUtility*)getUtilityInstanceId(env,thiz)))
+ if (!utilityPtr)
{
LOGE(" ## verifyEd25519SignatureJni(): failure - invalid utility ptr=NULL");
}
@@ -170,12 +170,12 @@ JNIEXPORT jbyteArray OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz,
{
jbyteArray sha256Ret = 0;
- OlmUtility* utilityPtr = NULL;
+ OlmUtility* utilityPtr = getUtilityInstanceId(env, thiz);
jbyte* messagePtr = NULL;
LOGD("## sha256Jni(): IN");
- if (!(utilityPtr = (OlmUtility*)getUtilityInstanceId(env,thiz)))
+ if (!utilityPtr)
{
LOGE(" ## sha256Jni(): failure - invalid utility ptr=NULL");
}