diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt index ee3bea50..c8d9aa45 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/log/MessageLogCollector.kt @@ -22,18 +22,16 @@ open class MessageLogCollector { // in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData open val messageLogWithoutSensitiveData: List - get() = messageLog.map { MessageLogEntry(removeSensitiveDataFromMessage(it.message, it.bank), it.time, it.bank) } + get() = messageLog.map { MessageLogEntry(removeSensitiveDataFromMessage(it.message, it.bank), it.type, it.time, it.bank) } open fun addMessageLog(message: String, type: MessageLogEntryType, bank: BankData) { val timeStamp = Date() - val messagePrefix = "${if (type == MessageLogEntryType.Sent) "Sending" else "Received"} message:\r\n" // currently no need to translate val prettyPrintMessage = prettyPrintHbciMessage(message) - val prettyPrintMessageWithPrefix = "$messagePrefix$prettyPrintMessage" - log.debug { prettyPrintMessageWithPrefix } + log.debug { "${if (type == MessageLogEntryType.Sent) "Sending" else "Received"} message:\r\n" + prettyPrintMessage } - messageLog.add(MessageLogEntry(prettyPrintMessageWithPrefix, timeStamp, bank)) + messageLog.add(MessageLogEntry(prettyPrintMessage, type, timeStamp, bank)) } protected open fun prettyPrintHbciMessage(message: String): String { diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt index 94a54fbc..942aebf5 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt @@ -4,13 +4,14 @@ import net.dankito.utils.multiplatform.Date open class MessageLogEntry( - val message: String, - val time: Date, - val bank: BankData + open val message: String, + open val type: MessageLogEntryType, + open val time: Date, + open val bank: BankData ) { override fun toString(): String { - return message + return "$type $message" } } \ No newline at end of file diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt index 034b3602..3e0d0850 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntry.kt @@ -4,9 +4,10 @@ import net.dankito.utils.multiplatform.Date open class MessageLogEntry( - val message: String, - val time: Date, - val bank: TypedBankData + open val message: String, + open val type: MessageLogEntryType, + open val time: Date, + open val bank: TypedBankData ) { override fun toString(): String { diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntryType.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntryType.kt new file mode 100644 index 00000000..a2013687 --- /dev/null +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/MessageLogEntryType.kt @@ -0,0 +1,10 @@ +package net.dankito.banking.ui.model + + +enum class MessageLogEntryType { + + Sent, + + Received + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index 2e76f849..d84958de 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -799,10 +799,14 @@ open class BankingPresenter( }) return logEntries.map { entry -> - MessageLogEntryDateFormatter.format(entry.time) + " " + entry.bank.bankCode + " " + entry.message + MessageLogEntryDateFormatter.format(entry.time) + " " + getMessageLogPrefix(entry) + "\r\n" + entry.bank.bankCode + " " + entry.message } } + protected open fun getMessageLogPrefix(entry: MessageLogEntry): String { + return "${if (entry.type == MessageLogEntryType.Sent) "Sending" else "Received"} message:" // TODO: translate + } + open fun showAddAccountDialog() { router.showAddAccountDialog(this) diff --git a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt index f9ae256b..acaa8c6a 100644 --- a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt +++ b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt @@ -17,6 +17,7 @@ import net.dankito.banking.fints.webclient.IWebClient import net.dankito.banking.fints.webclient.KtorWebClient import net.dankito.banking.extensions.toMoney import net.dankito.banking.fints.model.BankData +import net.dankito.banking.fints.model.MessageLogEntryType import net.dankito.banking.fints.response.client.FinTsClientResponse import net.dankito.banking.ui.model.* import net.dankito.banking.ui.model.MessageLogEntry @@ -54,7 +55,14 @@ open class fints4kBankingClient( override val messageLogWithoutSensitiveData: List - get() = client.messageLogWithoutSensitiveData.map { MessageLogEntry(it.message, it.time, bank) } + get() = client.messageLogWithoutSensitiveData.map { MessageLogEntry(it.message, map(it.type), it.time, bank) } + + protected open fun map(type: MessageLogEntryType): net.dankito.banking.ui.model.MessageLogEntryType { + return when (type) { + MessageLogEntryType.Sent -> net.dankito.banking.ui.model.MessageLogEntryType.Sent + MessageLogEntryType.Received -> net.dankito.banking.ui.model.MessageLogEntryType.Received + } + } override fun addAccountAsync(callback: (AddAccountResponse) -> Unit) {