move getOlmLibVersionJni
This commit is contained in:
parent
ffb40326ff
commit
2e77e39579
5 changed files with 23 additions and 23 deletions
|
@ -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.<br>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue