diff --git a/ios/Classes/DCWrapper/DCChatIdWrapper.swift b/ios/Classes/DCWrapper/DCChatIdWrapper.swift new file mode 100644 index 0000000..34d2929 --- /dev/null +++ b/ios/Classes/DCWrapper/DCChatIdWrapper.swift @@ -0,0 +1,48 @@ +/* + * 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. + */ + +import Foundation + +class DcChatIdWrapper { + var chatId: Int32 = 0 + var totalNumberOfParts: Int32 = 0 +} diff --git a/ios/Classes/DCWrapper/DCContext.swift b/ios/Classes/DCWrapper/DCContext.swift index 47fb313..1476d24 100644 --- a/ios/Classes/DCWrapper/DCContext.swift +++ b/ios/Classes/DCWrapper/DCContext.swift @@ -357,6 +357,24 @@ class DcContext { func getNextMedia(messageId: UInt32, dir: Int32, msgTypeOne: Int32, msgTypeTwo: Int32, msgTypeThree: Int32) -> UInt32 { return dc_get_next_media(DcContext.contextPointer, messageId, dir, msgTypeOne, msgTypeTwo, msgTypeThree) } + + func decryptMessageInMemory(contentType: String, content: String, senderAddress: String, chatIdWrapper: DcChatIdWrapper) -> String? { +// var totalNumberOfParts: UnsafeMutablePointer? +// var chatId: UnsafeMutablePointer? +// +// guard let cMessage = dc_decrypt_message_in_memory( +// DcContext.contextPointer, +// contentType, +// content, +// senderAddress, +// 0, +// totalNumberOfParts, +// chatId) else { +// return nil +// } +// return String(cString: cMessage) + return nil + } // MARK: - General diff --git a/ios/Classes/Handler/ContextCallHandler.swift b/ios/Classes/Handler/ContextCallHandler.swift index 2af90ce..3fbe98b 100644 --- a/ios/Classes/Handler/ContextCallHandler.swift +++ b/ios/Classes/Handler/ContextCallHandler.swift @@ -181,6 +181,8 @@ class ContextCallHandler: MethodCallHandling { getContactIdByAddress(methodCall: call, result: result) case Method.Context.GET_NEXT_MEDIA: getNextMedia(methodCall: call, result: result) + case Method.Context.DECRYPT_IN_MEMORY: + decryptMessageInMemory(methodCall: call, result: result) default: Utils.logEventAndDelegate(logLevel: SwiftyBeaver.Level.error, message: "Context: Failing for \(call.method)") result(FlutterMethodNotImplemented) @@ -366,6 +368,23 @@ class ContextCallHandler: MethodCallHandling { result(nextMessageId) } + + fileprivate func decryptMessageInMemory(methodCall: FlutterMethodCall, result: FlutterResult) { +// if !methodCall.contains(keys: [Argument.CONTENT, Argument.CONTENT_TYPE, Argument.ADDRESS]) { +// Method.Error.missingArgument("'\(Argument.CONTENT)', '\(Argument.CONTENT_TYPE)' or '\(Argument.ADDRESS)'", result: result) +// return +// } +// +// guard let content = methodCall.stringValue(for: Argument.CONTENT, result: result), +// let contentType = methodCall.stringValue(for: Argument.CONTENT_TYPE, result: result), +// let address = methodCall.stringValue(for: Argument.ADDRESS, result: result) else { +// Method.Error.missingArgumentValues(for: [Argument.CONTENT, Argument.CONTENT_TYPE, Argument.ADDRESS], result: result) +// return +// } + + //TODO: Finish Implementation!!! +// context.decryptMessageInMemory(contentType: contentType, content: content, senderAddress: address, chatIdWrapper: <#T##DcChatIdWrapper#>) + } // MARK: - Chat Related diff --git a/ios/Classes/Helper/Argument.swift b/ios/Classes/Helper/Argument.swift index 7dd1cf3..887b878 100644 --- a/ios/Classes/Helper/Argument.swift +++ b/ios/Classes/Helper/Argument.swift @@ -81,6 +81,8 @@ struct Argument { static let MESSAGE_TYPE_TWO = "messageTypeTwo" static let MESSAGE_TYPE_THREE = "messageTypeThree" static let MINIMAL_SETUP = "minimalSetup" + static let CONTENT = "content" + static let CONTENT_TYPE = "contentType" struct Error { static let MISSING = "1" diff --git a/ios/Classes/Helper/Method.swift b/ios/Classes/Helper/Method.swift index 79b6887..b19e0aa 100644 --- a/ios/Classes/Helper/Method.swift +++ b/ios/Classes/Helper/Method.swift @@ -218,6 +218,7 @@ extension Method { static let GET_CONTACT_ID_BY_ADDRESS = "context_getContactIdByAddress" static let GET_NEXT_MEDIA = "context_getNextMedia" static let CLOSE = "context_close" + static let DECRYPT_IN_MEMORY = "context_decryptInMemory" } }