diff --git a/android/jni/dc_wrapper.c b/android/jni/dc_wrapper.c index 9462765..d085d8c 100644 --- a/android/jni/dc_wrapper.c +++ b/android/jni/dc_wrapper.c @@ -616,12 +616,6 @@ JNIEXPORT jint Java_com_b44t_messenger_DcContext_getFreshMsgCount(JNIEnv *env, j } -JNIEXPORT jint Java_com_b44t_messenger_DcContext_estimateDeletionCount(JNIEnv *env, jobject obj, jboolean from_server, jlong seconds) -{ - return dc_estimate_deletion_cnt(get_dc_context(env, obj), from_server, seconds); -} - - JNIEXPORT jlong Java_com_b44t_messenger_DcContext_getMsgCPtr(JNIEnv *env, jobject obj, jint id) { @@ -961,14 +955,18 @@ JNIEXPORT jint Java_com_b44t_messenger_DcContext_isCoiMessageFilterEnabled(JNIEn return (jint)dc_get_coi_message_filter(get_dc_context(env, obj)); } -JNIEXPORT jstring Java_com_b44t_messenger_DcContext_decryptMessageInMemory(JNIEnv *env, jobject obj, jstring contentType, jstring content, jstring senderAddr) +JNIEXPORT jstring Java_com_b44t_messenger_DcContext_decryptMessageInMemory(JNIEnv *env, jobject obj, jstring contentType, jstring content, jstring senderAddr, jobject chatIdWrapper) { CHAR_REF(contentType); CHAR_REF(content); CHAR_REF(senderAddr); int partCount; - char* temp = dc_decrypt_message_in_memory(get_dc_context(env, obj), contentTypePtr, contentPtr, senderAddrPtr, 0, &partCount); - jstring ret = JSTRING_NEW(temp); + int chat_id; + char* temp = dc_decrypt_message_in_memory(get_dc_context(env, obj), contentTypePtr, contentPtr, senderAddrPtr, 0, &partCount, &chat_id); + jclass cls = (*env)->GetObjectClass(env, chatIdWrapper); + jfieldID fid = (*env)->GetFieldID(env,cls,"chatId","I"); + (*env)->SetIntField(env,chatIdWrapper,fid,chat_id); + jstring ret = JSTRING_NEW(temp); free(temp); CHAR_UNREF(contentType); CHAR_UNREF(content); diff --git a/android/src/main/java/com/b44t/messenger/ChatIdWrapper.java b/android/src/main/java/com/b44t/messenger/ChatIdWrapper.java new file mode 100644 index 0000000..8de575d --- /dev/null +++ b/android/src/main/java/com/b44t/messenger/ChatIdWrapper.java @@ -0,0 +1,5 @@ +package com.b44t.messenger; + +public class ChatIdWrapper { + public int chatId; +} diff --git a/android/src/main/java/com/b44t/messenger/DcContext.java b/android/src/main/java/com/b44t/messenger/DcContext.java index bc9cb6b..f96c610 100644 --- a/android/src/main/java/com/b44t/messenger/DcContext.java +++ b/android/src/main/java/com/b44t/messenger/DcContext.java @@ -194,7 +194,7 @@ protected void finalize() throws Throwable { public native void setCoiMessageFilter (int mode, int id); public native int isCoiMessageFilterEnabled(); public native void validateWebPush (String uid, String msg, int id); - public native String decryptMessageInMemory (String contentType, String content, String senderAddress); + public native String decryptMessageInMemory (String contentType, String content, String senderAddress, ChatIdWrapper chatIdWrapper); /** * @return true if at least one chat has location streaming enabled diff --git a/android/src/main/java/com/openxchange/deltachatcore/handlers/ContextCallHandler.java b/android/src/main/java/com/openxchange/deltachatcore/handlers/ContextCallHandler.java index 14c2c03..706e1ba 100644 --- a/android/src/main/java/com/openxchange/deltachatcore/handlers/ContextCallHandler.java +++ b/android/src/main/java/com/openxchange/deltachatcore/handlers/ContextCallHandler.java @@ -42,6 +42,9 @@ package com.openxchange.deltachatcore.handlers; +import android.util.Log; + +import com.b44t.messenger.ChatIdWrapper; import com.b44t.messenger.DcChat; import com.b44t.messenger.DcChatlist; import com.b44t.messenger.DcContact; @@ -1200,6 +1203,7 @@ private void retrySendingPendingMessages(MethodChannel.Result result) { } private void decryptMessageInMemory(MethodCall methodCall, MethodChannel.Result result) { + Log.d("dboehrs", "decryptMessageInMemory: started"); if (!hasArgumentKeys(methodCall, ARGUMENT_CONTENT_TYPE, ARGUMENT_CONTENT, ARGUMENT_ADDRESS)) { resultErrorArgumentMissing(result); return; @@ -1219,7 +1223,9 @@ private void decryptMessageInMemory(MethodCall methodCall, MethodChannel.Result resultErrorArgumentMissingValue(result); return; } - String plainText = dcContext.decryptMessageInMemory(contentType, content, senderAddress); + ChatIdWrapper chatIdWrapper = new ChatIdWrapper(); + String plainText = dcContext.decryptMessageInMemory(contentType, content, senderAddress, chatIdWrapper); + Log.d("dboehrs", "decryptMessageInMemory: finished with" + chatIdWrapper.chatId); result.success(plainText); } } \ No newline at end of file