From 034fa6be40b1a354dad5394cdb43651f435f8adb Mon Sep 17 00:00:00 2001 From: pedroGitt Date: Tue, 18 Oct 2016 15:59:36 +0200 Subject: - Add new API for OlmUtility - Introducing namespace AndroidOlmSdk - Fix logs (function names mixed up) - Add new check based on the calling java object instance type (IsInstanceOf()) - Fix return value for getXXXInstanceId() in case of failure. Now 0 is returned. --- .../android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp') 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 860ff3e..a10b8e0 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 @@ -16,6 +16,8 @@ #include "olm_account.h" +using namespace AndroidOlmSdk; + /** * Init memory allocation for account creation. * @return valid memory allocation, NULL otherwise @@ -264,36 +266,36 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(oneTimeKeysJni)(JNIEnv *env, jobject t size_t keysResult; jbyteArray byteArrayRetValue = NULL; - LOGD("## oneTimeKeys(): accountPtr =%p",accountPtr); + LOGD("## oneTimeKeysJni(): IN"); if(NULL == (accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz))) { - LOGE("## oneTimeKeys(): failure - invalid Account ptr"); + LOGE("## oneTimeKeysJni(): failure - invalid Account ptr"); } else { // keys memory allocation keysLength = olm_account_one_time_keys_length(accountPtr); if(NULL == (keysBytesPtr=(uint8_t *)malloc(keysLength*sizeof(uint8_t)))) { - LOGE("## oneTimeKeys(): failure - one time keys array OOM"); + LOGE("## oneTimeKeysJni(): failure - one time keys array OOM"); } else { // retrieve key pairs in keysBytesPtr keysResult = olm_account_one_time_keys(accountPtr, keysBytesPtr, keysLength); if(keysResult == olm_error()) { const char *errorMsgPtr = olm_account_last_error(accountPtr); - LOGE("## oneTimeKeys(): failure - error getting one time keys Msg=%s",errorMsgPtr); + LOGE("## oneTimeKeysJni(): failure - error getting one time keys Msg=%s",errorMsgPtr); } else { // allocate the byte array to be returned to java if(NULL == (byteArrayRetValue=env->NewByteArray(keysLength))) { - LOGE("## oneTimeKeys(): failure - return byte array OOM"); + LOGE("## oneTimeKeysJni(): failure - return byte array OOM"); } else { env->SetByteArrayRegion(byteArrayRetValue, 0/*offset*/, keysLength, (const jbyte*)keysBytesPtr); - LOGD("## oneTimeKeys(): success"); + LOGD("## oneTimeKeysJni(): success"); } } -- cgit v1.2.3