Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge branch 'app/501_pushSupportAndroid' of https://github.com/open-…
Browse files Browse the repository at this point in the history
…xchange/flutter-deltachat-core into app/501_pushSupportAndroid
  • Loading branch information
Boehrsi committed Jun 2, 2020
2 parents 5fa908c + e37f571 commit 4b8b189
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
16 changes: 7 additions & 9 deletions android/jni/dc_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions android/src/main/java/com/b44t/messenger/ChatIdWrapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.b44t.messenger;

public class ChatIdWrapper {
public int chatId;
}
2 changes: 1 addition & 1 deletion android/src/main/java/com/b44t/messenger/DcContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}

0 comments on commit 4b8b189

Please sign in to comment.