From 2e77e3957945b52f92e4b72a8be90202ef7b7d69 Mon Sep 17 00:00:00 2001 From: ylecollen Date: Wed, 21 Dec 2016 16:26:07 +0100 Subject: move getOlmLibVersionJni --- .../OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp | 23 +++++----------------- .../OlmLibSdk/olm-sdk/src/main/jni/olm_account.h | 2 -- .../olm-sdk/src/main/jni/olm_jni_helper.cpp | 3 +-- .../OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp | 14 +++++++++++++ .../OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h | 4 +++- 5 files changed, 23 insertions(+), 23 deletions(-) (limited to 'java') 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 68dcc0b..5d79ecb 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 @@ -113,7 +113,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(initNewAccountJni)(JNIEnv *env, jobject thi // create account accountRetCode = olm_create_account(accountPtr, (void*)randomBuffPtr, randomSize); if(accountRetCode == olm_error()) { - LOGE("## initNewAccount(): failure - account creation failed Msg=%s", (const char *)olm_account_last_error(accountPtr)); + LOGE("## initNewAccount(): failure - account creation failed Msg=%s", olm_account_last_error(accountPtr)); } LOGD("## initNewAccount(): success - OLM account created"); @@ -147,16 +147,16 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject size_t keysResult; jbyteArray byteArrayRetValue = NULL; - LOGD("## identityKeys(): accountPtr =%p",accountPtr); - if(NULL == (accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz))) { LOGE("## identityKeys(): failure - invalid Account ptr=NULL"); } else - { // identity keys allocation + { + LOGD("## identityKeys(): accountPtr =%p", accountPtr); + // identity keys allocation identityKeysLength = olm_account_identity_keys_length(accountPtr); - if(NULL == (identityKeysBytesPtr=(uint8_t*)malloc(identityKeysLength*sizeof(uint8_t)))) + if(NULL == (identityKeysBytesPtr=(uint8_t*)malloc(identityKeysLength))) { LOGE("## identityKeys(): failure - identity keys array OOM"); } @@ -459,20 +459,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz } -JNIEXPORT jstring OLM_MANAGER_FUNC_DEF(getOlmLibVersionJni)(JNIEnv* env, jobject thiz) -{ - uint8_t majorVer=0, minorVer=0, patchVer=0; - jstring returnValueStr=0; - char buff[150]; - - olm_get_library_version(&majorVer, &minorVer, &patchVer); - LOGD("## getOlmLibVersionJni(): Major=%d Minor=%d Patch=%d", majorVer, minorVer, patchVer); - - snprintf(buff, sizeof(buff), "%d.%d.%d", majorVer, minorVer, patchVer); - returnValueStr = env->NewStringUTF((const char*)buff); - return returnValueStr; -} /** * Serialize and encrypt account instance into a base64 string.
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h index b4bf0ef..d57c7d9 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h @@ -27,8 +27,6 @@ extern "C" { #endif -JNIEXPORT jstring OLM_MANAGER_FUNC_DEF(getOlmLibVersionJni)(JNIEnv *env, jobject thiz); - // account creation/destruction JNIEXPORT void OLM_ACCOUNT_FUNC_DEF(releaseAccountJni)(JNIEnv *env, jobject thiz); JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(initNewAccountJni)(JNIEnv *env, jobject thiz); 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 82c3e28..25f3193 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 @@ -32,7 +32,6 @@ using namespace AndroidOlmSdk; bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize) { bool retCode = false; - struct timeval timeValue; int bufferLen = aRandomSize*sizeof(uint8_t); if(NULL == aBuffer2Ptr) @@ -98,7 +97,7 @@ bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize) if (!secureRandomSucceeds) { LOGE("## setRandomInBuffer(): SecureRandom failed, use a fallback"); - + struct timeval timeValue; gettimeofday(&timeValue, NULL); srand(timeValue.tv_usec); // init seed 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 19a045b..0e51940 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 @@ -36,6 +36,20 @@ OlmUtility* initializeUtilityMemory() return utilityPtr; } +JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(getOlmLibVersionJni)(JNIEnv* env, jobject thiz) +{ + uint8_t majorVer=0, minorVer=0, patchVer=0; + jstring returnValueStr=0; + char buff[150]; + + olm_get_library_version(&majorVer, &minorVer, &patchVer); + LOGD("## getOlmLibVersionJni(): Major=%d Minor=%d Patch=%d", majorVer, minorVer, patchVer); + + snprintf(buff, sizeof(buff), "%d.%d.%d", majorVer, minorVer, patchVer); + returnValueStr = env->NewStringUTF((const char*)buff); + + return returnValueStr; +} JNIEXPORT jlong OLM_UTILITY_FUNC_DEF(initUtilityJni)(JNIEnv *env, jobject thiz) { diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h index 0bbbb52..b807c6d 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h @@ -26,8 +26,10 @@ #ifdef __cplusplus extern "C" { #endif - JNIEXPORT jlong OLM_UTILITY_FUNC_DEF(initUtilityJni)(JNIEnv *env, jobject thiz); + +JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(getOlmLibVersionJni)(JNIEnv *env, jobject thiz); + JNIEXPORT void OLM_UTILITY_FUNC_DEF(releaseUtilityJni)(JNIEnv *env, jobject thiz); JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jstring aSignature, jstring aKey, jstring aMessage); JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jstring aMessageToHash); -- cgit v1.2.3