diff --git a/android/src/main/java/com/openxchange/deltachatcore/DeltaChatCorePlugin.java b/android/src/main/java/com/openxchange/deltachatcore/DeltaChatCorePlugin.java index a9d26e2..86f2de4 100644 --- a/android/src/main/java/com/openxchange/deltachatcore/DeltaChatCorePlugin.java +++ b/android/src/main/java/com/openxchange/deltachatcore/DeltaChatCorePlugin.java @@ -44,7 +44,6 @@ import android.content.Context; -import android.util.Log; import com.b44t.messenger.DcChat; import com.b44t.messenger.DcContact; @@ -123,7 +122,6 @@ public DeltaChatCorePlugin() { @Override public void onAttachedToEngine(FlutterPluginBinding binding) { - Log.d("dboehrs" + this.hashCode(), "onAttachedToEngine:"); logEventAndDelegate(eventChannelHandler, INFO, TAG, "Attaching plugin via v2 embedding"); context = binding.getApplicationContext(); messenger = binding.getBinaryMessenger(); @@ -133,7 +131,6 @@ public void onAttachedToEngine(FlutterPluginBinding binding) { @Override public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { - Log.d("dboehrs" + this.hashCode(), "onDetachedFromEngine: "); logEventAndDelegate(eventChannelHandler, INFO, TAG, "Detaching plugin via v2 embedding"); context = null; messenger = null; @@ -240,7 +237,6 @@ private void init(MethodCall methodCall, Result result) { private void tearDown(Result result) { logEventAndDelegate(eventChannelHandler, INFO, TAG, "Teardown started"); - Log.d("dboehrs" + this.hashCode(), "tearDown: "); nativeInteractionManager.tearDown(); nativeInteractionManager = null; contextCallHandler = null; 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 706e1ba..08bab5a 100644 --- a/android/src/main/java/com/openxchange/deltachatcore/handlers/ContextCallHandler.java +++ b/android/src/main/java/com/openxchange/deltachatcore/handlers/ContextCallHandler.java @@ -42,8 +42,6 @@ package com.openxchange.deltachatcore.handlers; -import android.util.Log; - import com.b44t.messenger.ChatIdWrapper; import com.b44t.messenger.DcChat; import com.b44t.messenger.DcChatlist; @@ -54,6 +52,8 @@ import com.openxchange.deltachatcore.IdCache; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; @@ -1203,7 +1203,6 @@ 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; @@ -1225,7 +1224,7 @@ private void decryptMessageInMemory(MethodCall methodCall, MethodChannel.Result } ChatIdWrapper chatIdWrapper = new ChatIdWrapper(); String plainText = dcContext.decryptMessageInMemory(contentType, content, senderAddress, chatIdWrapper); - Log.d("dboehrs", "decryptMessageInMemory: finished with" + chatIdWrapper.chatId); - result.success(plainText); + List data = Arrays.asList(chatIdWrapper.chatId, plainText); + result.success(data); } } \ No newline at end of file diff --git a/lib/delta_chat_core.dart b/lib/delta_chat_core.dart index d1845ac..9003046 100644 --- a/lib/delta_chat_core.dart +++ b/lib/delta_chat_core.dart @@ -51,6 +51,7 @@ import 'package:logging/logging.dart'; export 'package:delta_chat_core/src/types/chat_summary.dart'; export 'package:delta_chat_core/src/types/event.dart'; export 'package:delta_chat_core/src/types/qrcode_result.dart'; +export 'package:delta_chat_core/src/types/decrypted_chat_message.dart'; export 'src/base.dart'; export 'src/chat.dart'; diff --git a/lib/src/context.dart b/lib/src/context.dart index 6b53a83..6571ff2 100644 --- a/lib/src/context.dart +++ b/lib/src/context.dart @@ -404,7 +404,7 @@ class Context { return await core.invokeMethod(methodGetNextMedia, getNextMediaArguments(messageId, dir, messageTypeOne, messageTypeTwo, messageTypeThree)); } - Future decryptInMemory(String contentType, String content, String senderAddress) async { + Future> decryptInMemory(String contentType, String content, String senderAddress) async { return await core.invokeMethod(methodDecryptInMemory, getDecryptInMemoryArguments(contentType, content, senderAddress)); } diff --git a/lib/src/types/decrypted_chat_message.dart b/lib/src/types/decrypted_chat_message.dart new file mode 100644 index 0000000..86a21cc --- /dev/null +++ b/lib/src/types/decrypted_chat_message.dart @@ -0,0 +1,57 @@ +/* + * OPEN-XCHANGE legal information + * + * All intellectual property rights in the Software are protected by + * international copyright laws. + * + * + * In some countries OX, OX Open-Xchange and open xchange + * as well as the corresponding Logos OX Open-Xchange and OX are registered + * trademarks of the OX Software GmbH group of companies. + * The use of the Logos is not covered by the Mozilla Public License 2.0 (MPL 2.0). + * Instead, you are allowed to use these Logos according to the terms and + * conditions of the Creative Commons License, Version 2.5, Attribution, + * Non-commercial, ShareAlike, and the interpretation of the term + * Non-commercial applicable to the aforementioned license is published + * on the web site https://www.open-xchange.com/terms-and-conditions/. + * + * Please make sure that third-party modules and libraries are used + * according to their respective licenses. + * + * Any modifications to this package must retain all copyright notices + * of the original copyright holder(s) for the original code used. + * + * After any such modifications, the original and derivative code shall remain + * under the copyright of the copyright holder(s) and/or original author(s) as stated here: + * https://www.open-xchange.com/legal/. The contributing author shall be + * given Attribution for the derivative code and a license granting use. + * + * Copyright (C) 2016-2020 OX Software GmbH + * Mail: info@open-xchange.com + * + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License 2.0 + * for more details. + */ + +const indexChatId = 0; +const indexContent = 1; + +class DecryptedChatMessage { + int chatId; + String content; + + DecryptedChatMessage.fromMethodChannel(List data) { + if (data is! List) { + throw ArgumentError("Given data is no List, can't create DecryptedPushMessage object"); + } + chatId = data[indexChatId]; + content = data[indexContent]; + } +}