From 0263cd3039568bd5e5b374451efc0e37c2629592 Mon Sep 17 00:00:00 2001 From: pedroGitt Date: Mon, 28 Nov 2016 11:53:54 +0100 Subject: Remove un used code --- .../OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp | 6 -- .../OlmLibSdk/olm-sdk/src/main/jni/olm_jni.h | 13 --- .../olm-sdk/src/main/jni/olm_jni_helper.cpp | 95 ---------------------- 3 files changed, 114 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 9e6ed2a..c8c6e8a 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 @@ -18,12 +18,6 @@ using namespace AndroidOlmSdk; -/*jstring serializeDataWithKey(JNIEnv *env, jobject thiz, - jstring aKey, - jobject aErrorMsg, - olmPickleLengthFuncPtr aGetLengthFunc, - olmPickleFuncPtr aGetPickleFunc, - olmLastErrorFuncPtr aGetLastErrorFunc);*/ /** * Init memory allocation for account creation. 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 a5cae46..d70dc58 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 @@ -62,19 +62,6 @@ namespace AndroidOlmSdk } -// function pointer templates -template using olmPickleLengthFuncPtr = size_t (*)(T); -template using olmPickleFuncPtr = size_t (*)(T, void const *, size_t, void *, size_t); -template using olmLastErrorFuncPtr = const char* (*)(T); - -template -jstring serializeDataWithKey(JNIEnv *env, jobject thiz, - jstring aKey, - jobject aErrorMsg, - olmPickleLengthFuncPtr aGetLengthFunc, - olmPickleFuncPtr aGetPickleFunc, - olmLastErrorFuncPtr aGetLastErrorFunc); - #ifdef __cplusplus extern "C" { #endif 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 561010d..a0525dc 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 @@ -178,101 +178,6 @@ jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) } -template -jstring serializeDataWithKey(JNIEnv *env, jobject thiz, - jstring aKey, - jobject aErrorMsg, - olmPickleLengthFuncPtr aGetLengthFunc, - olmPickleFuncPtr aGetPickleFunc, - olmLastErrorFuncPtr aGetLastErrorFunc) -{ - jstring pickledDataRetValue = 0; - jclass errorMsgJClass = 0; - jmethodID errorMsgMethodId = 0; - jstring errorJstring = 0; - const char *keyPtr = NULL; - void *pickledPtr = NULL; - T accountPtr = NULL; - - LOGD("## serializeDataWithKeyJni(): IN"); - - if(NULL == (accountPtr = (T)getAccountInstanceId(env,thiz))) - { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid account ptr"); - } - else if(0 == aKey) - { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid key"); - } - else if(0 == aErrorMsg) - { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid error object"); - } - else if(0 == (errorMsgJClass = env->GetObjectClass(aErrorMsg))) - { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error class"); - } - else if(0 == (errorMsgMethodId = env->GetMethodID(errorMsgJClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"))) - { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID"); - } - else if(NULL == (keyPtr = env->GetStringUTFChars(aKey, 0))) - { - LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM"); - } - else - { - size_t pickledLength = aGetLengthFunc(accountPtr); - size_t keyLength = (size_t)env->GetStringUTFLength(aKey); - LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast(pickledLength), static_cast(keyLength)); - LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); - - if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t)))) - { - LOGE(" ## serializeDataWithKeyJni(): failure - pickledPtr buffer OOM"); - } - else - { - size_t result = aGetPickleFunc(accountPtr, - (void const *)keyPtr, - keyLength, - (void*)pickledPtr, - pickledLength); - if(result == olm_error()) - { - const char *errorMsgPtr = aGetLastErrorFunc(accountPtr); - LOGE(" ## serializeDataWithKeyJni(): failure - olm_pickle_account() Msg=%s",errorMsgPtr); - - if(0 != (errorJstring = env->NewStringUTF(errorMsgPtr))) - { - env->CallObjectMethod(aErrorMsg, errorMsgMethodId, errorJstring); - } - } - else - { - // build success output - (static_cast(pickledPtr))[pickledLength] = static_cast('\0'); - pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr); - LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast(result), static_cast(pickledPtr)); - } - } - } - - // free alloc - if(NULL != keyPtr) - { - env->ReleaseStringUTFChars(aKey, keyPtr); - } - - if(NULL != pickledPtr) - { - free(pickledPtr); - } - - return pickledDataRetValue; -} - - /** * Convert a C string into a UTF-8 format string. * The conversion is performed in JAVA side to workaround the issue in NewStringUTF(). -- cgit v1.2.3