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

Commit

Permalink
Adds incomplete(!) implementation for 'decryptMessageInMemory`
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Gregor committed Jun 5, 2020
1 parent a677e08 commit d6c669e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
48 changes: 48 additions & 0 deletions ios/Classes/DCWrapper/DCChatIdWrapper.swift
Original file line number Diff line number Diff line change
@@ -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: [email protected]
*
*
* 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
}
18 changes: 18 additions & 0 deletions ios/Classes/DCWrapper/DCContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int32>?
// var chatId: UnsafeMutablePointer<Int32>?
//
// 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

Expand Down
19 changes: 19 additions & 0 deletions ios/Classes/Handler/ContextCallHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/Helper/Argument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ios/Classes/Helper/Method.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

}
Expand Down

0 comments on commit d6c669e

Please sign in to comment.