diff --git a/fints4k/build.gradle b/fints4k/build.gradle index 05dcb423..4bd9f6ba 100644 --- a/fints4k/build.gradle +++ b/fints4k/build.gradle @@ -4,6 +4,17 @@ plugins { } +allprojects { + configurations.all { + resolutionStrategy { + // otherwise Kotlin throws an exception even though it is on the classpath: + // "Ktor native HttpClient requires kotlinx.coroutines version with `native-mt` suffix (like `1.3.9-native-mt`)" + force("org.jetbrains.kotlinx:kotlinx-coroutines-core:${coroutinesVersion}-native-mt") + } + } +} + + kotlin { jvm { compilations.all { @@ -31,13 +42,13 @@ kotlin { } } -// def hostOs = System.getProperty("os.name") -// def isMingwX64 = hostOs.startsWith("Windows") -// def nativeTarget -// if (hostOs == "Mac OS X") nativeTarget = macosX64('native') { binaries.executable() } -// else if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries.executable() } -// else if (isMingwX64) nativeTarget = mingwX64("native") { binaries.executable() } -// else throw new GradleException("Host OS is not supported in Kotlin/Native.") + def hostOs = System.getProperty("os.name") + def isMingwX64 = hostOs.startsWith("Windows") + def nativeTarget + if (hostOs == "Mac OS X") nativeTarget = macosX64('native') + else if (hostOs == "Linux") nativeTarget = linuxX64("native") + else if (isMingwX64) nativeTarget = mingwX64("native") + else throw new GradleException("Host OS is not supported in Kotlin/Native.") sourceSets { @@ -120,7 +131,7 @@ private val jsJodaTz = JsJodaTimeZoneModule nativeMain { dependencies { // ktor Native needs "-native-mt" coroutines version. Export it so that referencing applications don't need to import it on their own - api"org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion-native-mt" + api "org.jetbrains.kotlinx:kotlinx-coroutines-core:${coroutinesVersion}-native-mt" // requires cURL to be installed on your system implementation "io.ktor:ktor-client-curl:$ktorVersion" diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/JobContext.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/JobContext.kt index 7e9c4036..cdbe728b 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/JobContext.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/JobContext.kt @@ -53,8 +53,8 @@ open class JobContext( open fun startNewDialog(closeDialog: Boolean = true, dialogId: String = DialogContext.InitialDialogId, - versionOfSecurityProcedure: VersionDesSicherheitsverfahrens = VersionDesSicherheitsverfahrens.Version_2, - chunkedResponseHandler: ((BankResponse) -> Unit)? = dialog.chunkedResponseHandler) : DialogContext { + versionOfSecurityProcedure: VersionDesSicherheitsverfahrens = VersionDesSicherheitsverfahrens.Version_2, + chunkedResponseHandler: ((BankResponse) -> Unit)? = dialog.chunkedResponseHandler) : DialogContext { val newDialogContext = DialogContext(closeDialog, dialogId, chunkedResponseHandler) diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt index 7f4b340d..45e6ed67 100644 --- a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt @@ -37,13 +37,13 @@ abstract class FinTsTestBase { const val ControlReference = "4477" - val Bank = BankData(BankCode, CustomerId, Pin, BankFinTsServerAddress, Bic, "", BankCountryCode, selectedTanMethod = TanMethod("chipTAN-optisch", SecurityFunction, TanMethodType.ChipTanFlickercode), selectedLanguage = Language) + val Bank = createTestBank() val Currency = "EUR" val AccountHolderName = "Martina Musterfrau" - val Account = AccountData(CustomerId, null, BankCountryCode, BankCode, Iban, CustomerId, AccountType.Girokonto, Currency, AccountHolderName, null, null, listOf(), listOf()) + val Account = createTestAccount() const val ProductName = "FinTS-TestClient25Stellen" @@ -59,11 +59,20 @@ abstract class FinTsTestBase { init { Bank.changeTanMediumParameters = ChangeTanMediaParameters(JobParameters("", 1, 1, 1, ":0:0"), false, false, false, false, false, listOf()) } + + + fun createTestBank(): BankData { + return BankData(BankCode, CustomerId, Pin, BankFinTsServerAddress, Bic, "", BankCountryCode, selectedTanMethod = TanMethod("chipTAN-optisch", SecurityFunction, TanMethodType.ChipTanFlickercode), selectedLanguage = Language) + } + + fun createTestAccount(): AccountData { + return AccountData(CustomerId, null, BankCountryCode, BankCode, Iban, CustomerId, AccountType.Girokonto, Currency, AccountHolderName, null, null, listOf(), listOf()) + } } - protected open fun createContext(dialogId: String = DialogContext.InitialDialogId): JobContext { - val context = JobContext(JobContextType.AnonymousBankInfo, SimpleFinTsClientCallback(), Product, Bank) + protected open fun createContext(bank: BankData = Bank, dialogId: String = DialogContext.InitialDialogId): JobContext { + val context = JobContext(JobContextType.AnonymousBankInfo, SimpleFinTsClientCallback(), Product, bank) context.startNewDialog(dialogId = dialogId) return context diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/AssertExtensions.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/AssertExtensions.kt index f0ed5177..fa014afd 100644 --- a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/AssertExtensions.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/AssertExtensions.kt @@ -67,7 +67,6 @@ inline fun assertThrows(action: () -> Unit) { action() fail("action() didn't throw any exception. Expected was ${T::class.qualifiedName}") } catch (throwable: Throwable) { - println("Throwable is of type ${throwable::class.simpleName}: $throwable") assertTrue(throwable is T) } } \ No newline at end of file diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt index 7043ebb6..378db6ee 100644 --- a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt @@ -34,9 +34,12 @@ class MessageBuilderTest : FinTsTestBase() { } + // we need to create our own copy as otherwise Kotlin/Native throws an InvalidMutabilityException + private val bank = createTestBank() + @AfterTest fun tearDown() { - Bank.supportedJobs = listOf() + bank.supportedJobs = listOf() } @@ -44,7 +47,7 @@ class MessageBuilderTest : FinTsTestBase() { fun createAnonymousDialogInitMessage() { // given - val context = createContext() + val context = createContext(bank) // when val result = underTest.createAnonymousDialogInitMessage(context).createdMessage @@ -63,7 +66,7 @@ class MessageBuilderTest : FinTsTestBase() { // given val dialogId = createDialogId() - val context = createContext(dialogId) + val context = createContext(bank, dialogId) // when val result = underTest.createAnonymousDialogEndMessage(context).createdMessage ?: "" @@ -81,7 +84,7 @@ class MessageBuilderTest : FinTsTestBase() { fun createDialogInitMessage() { // given - val context = createContext() + val context = createContext(bank) // when val result = underTest.createSynchronizeCustomerSystemIdMessage(context).createdMessage ?: "" @@ -105,7 +108,7 @@ class MessageBuilderTest : FinTsTestBase() { // given val dialogId = createDialogId() - val context = createContext(dialogId) + val context = createContext(bank, dialogId) // when val result = underTest.createDialogEndMessage(context).createdMessage ?: "" @@ -126,10 +129,10 @@ class MessageBuilderTest : FinTsTestBase() { fun createGetTransactionsMessage_JobIsNotAllowed() { // given - val context = createContext() + val context = createContext(bank) // when - val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, Account)) + val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(bank, Account)) // then assertFalse(result.isJobAllowed) @@ -141,14 +144,14 @@ class MessageBuilderTest : FinTsTestBase() { // given val getTransactionsJob = JobParameters("HKKAZ", 1, 1, null, "HKKAZ:73:5") val getTransactionsJobWithPreviousVersion = JobParameters("HKKAZ", 1, 1, null, "HKKAZ:72:4") - Bank.supportedJobs = listOf(getTransactionsJob) + bank.supportedJobs = listOf(getTransactionsJob) val account = AccountData(CustomerId, null, BankCountryCode, BankCode, null, CustomerId, AccountType.Girokonto, "EUR", "", null, null, listOf(getTransactionsJob.jobName), listOf(getTransactionsJobWithPreviousVersion)) - Bank.addAccount(account) + bank.addAccount(account) - val context = createContext() + val context = createContext(bank) // when - val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, account)) + val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(bank, account)) // then assertTrue(result.isJobAllowed) @@ -160,19 +163,19 @@ class MessageBuilderTest : FinTsTestBase() { // given val getTransactionsJob = RetrieveAccountTransactionsParameters(JobParameters(CustomerSegmentId.AccountTransactionsMt940.id, 1, 1, null, "HIKAZS:73:5"), 180, true, false) - Bank.supportedJobs = listOf(getTransactionsJob) - Bank.pinInfo = PinInfo(getTransactionsJob, null, null, null, null, null, listOf(JobTanConfiguration(CustomerSegmentId.AccountTransactionsMt940.id, true))) + bank.supportedJobs = listOf(getTransactionsJob) + bank.pinInfo = PinInfo(getTransactionsJob, null, null, null, null, null, listOf(JobTanConfiguration(CustomerSegmentId.AccountTransactionsMt940.id, true))) val account = AccountData(CustomerId, null, BankCountryCode, BankCode, null, CustomerId, AccountType.Girokonto, "EUR", "", null, null, listOf(getTransactionsJob.jobName), listOf(getTransactionsJob)) - Bank.addAccount(account) + bank.addAccount(account) - val context = createContext() + val context = createContext(bank) val fromDate = LocalDate(2019, Month.AUGUST, 6) val toDate = LocalDate(2019, Month.OCTOBER, 21) val maxCountEntries = 99 // when - val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, account, false, fromDate, toDate, maxCountEntries)) + val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(bank, account, false, fromDate, toDate, maxCountEntries)) // then assertNotNull(result.createdMessage) @@ -194,12 +197,12 @@ class MessageBuilderTest : FinTsTestBase() { // given val getTransactionsJob = RetrieveAccountTransactionsParameters(JobParameters(CustomerSegmentId.AccountTransactionsMt940.id, 1, 1, null, "HIKAZS:73:5"), 180, true, false) - Bank.supportedJobs = listOf(getTransactionsJob) - Bank.pinInfo = PinInfo(getTransactionsJob, null, null, null, null, null, listOf(JobTanConfiguration(CustomerSegmentId.AccountTransactionsMt940.id, true))) + bank.supportedJobs = listOf(getTransactionsJob) + bank.pinInfo = PinInfo(getTransactionsJob, null, null, null, null, null, listOf(JobTanConfiguration(CustomerSegmentId.AccountTransactionsMt940.id, true))) val account = AccountData(CustomerId, null, BankCountryCode, BankCode, null, CustomerId, AccountType.Girokonto, "EUR", "", null, null, listOf(getTransactionsJob.jobName), listOf(getTransactionsJob)) - Bank.addAccount(account) + bank.addAccount(account) - val context = createContext() + val context = createContext(bank) val fromDate = LocalDate(2019, Month.AUGUST, 6) val toDate = LocalDate(2019, Month.OCTOBER, 21) @@ -208,7 +211,7 @@ class MessageBuilderTest : FinTsTestBase() { // when val result = underTest.createGetTransactionsMessage(context, // TODO: test Aufsetzpunkt / continuationId - GetAccountTransactionsParameter(Bank, account, false, fromDate, toDate, maxCountEntries, false)) + GetAccountTransactionsParameter(bank, account, false, fromDate, toDate, maxCountEntries, false)) // then assertNotNull(result.createdMessage) diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt index 426759db..bc7785d3 100644 --- a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt @@ -30,8 +30,14 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { } + // we need to create our own copy as otherwise Kotlin/Native throws an InvalidMutabilityException + private val bank = createTestBank() + + private val account = createTestAccount() + + init { - Bank.addAccount(Account) + bank.addAccount(account) } @@ -41,7 +47,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, false, false, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -58,7 +64,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, false, true, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -75,7 +81,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, true, false, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -92,7 +98,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, true, true, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(1, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -110,7 +116,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, false, false, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -127,7 +133,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, false, true, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -144,7 +150,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, true, false, false, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -161,7 +167,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, false, false, true, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when @@ -178,7 +184,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // given val parameters = ChangeTanMediaParameters(createEmptyJobParameters(), false, true, true, true, false, listOf()) - val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, Bank, NewActiveTanMedium, TAN, ATC, null, parameters) + val underTest = TanGeneratorTanMediumAnOderUmmelden(2, SegmentNumber, bank, NewActiveTanMedium, TAN, ATC, null, parameters) // when diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt index d037a219..06769eed 100644 --- a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt @@ -36,9 +36,6 @@ class Mt940ParserTest : FinTsTestBase() { val AccountStatement1ClosingBalanceAmount = Amount("13580,23") val AccountStatement1With2TransactionsClosingBalanceAmount = Amount("13148,13") - - val Mt940DateFormatter = DateFormatter("yyMMdd") - val BookingDateFormatter = DateFormatter("MMdd") } private val underTest = Mt940Parser() @@ -388,11 +385,13 @@ class Mt940ParserTest : FinTsTestBase() { private fun convertMt940Date(date: LocalDate): String { - return date.format(Mt940DateFormatter) + // don't use DateFormatter for this as it's not implemented in Kotlin/Native + return (date.year % 100).toString() + date.monthNumber.toStringWithTwoDigits() + date.dayOfMonth.toStringWithTwoDigits() } private fun convertToShortBookingDate(date: LocalDate): String { - return date.format(BookingDateFormatter) + // don't use DateFormatter for this as it's not implemented in Kotlin/Native + return date.monthNumber.toStringWithTwoDigits() + date.dayOfMonth.toStringWithTwoDigits() } } \ No newline at end of file diff --git a/multiplatform-utils/build.gradle b/multiplatform-utils/build.gradle index 6e668fa7..4d40ae0a 100644 --- a/multiplatform-utils/build.gradle +++ b/multiplatform-utils/build.gradle @@ -34,13 +34,13 @@ kotlin { } } -// def hostOs = System.getProperty("os.name") -// def isMingwX64 = hostOs.startsWith("Windows") -// def nativeTarget -// if (hostOs == "Mac OS X") nativeTarget = macosX64('native') { binaries.executable() } -// else if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries.executable() } -// else if (isMingwX64) nativeTarget = mingwX64("native") { binaries.executable() } -// else throw new GradleException("Host OS is not supported in Kotlin/Native.") + def hostOs = System.getProperty("os.name") + def isMingwX64 = hostOs.startsWith("Windows") + def nativeTarget + if (hostOs == "Mac OS X") nativeTarget = macosX64('native') + else if (hostOs == "Linux") nativeTarget = linuxX64("native") + else if (isMingwX64) nativeTarget = mingwX64("native") + else throw new GradleException("Host OS is not supported in Kotlin/Native.") sourceSets { diff --git a/multiplatform-utils/src/commonMain/kotlin/net/dankito/utils/multiplatform/os/OsType.kt b/multiplatform-utils/src/commonMain/kotlin/net/dankito/utils/multiplatform/os/OsType.kt index 3fe3d65f..5a8e2463 100644 --- a/multiplatform-utils/src/commonMain/kotlin/net/dankito/utils/multiplatform/os/OsType.kt +++ b/multiplatform-utils/src/commonMain/kotlin/net/dankito/utils/multiplatform/os/OsType.kt @@ -7,6 +7,8 @@ enum class OsType { Android, - iOS + iOS, + + Native // TODO: get if running on Linux, Windows or macOs } \ No newline at end of file diff --git a/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/DateFormatter.kt b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/DateFormatter.kt new file mode 100644 index 00000000..90db9f72 --- /dev/null +++ b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/DateFormatter.kt @@ -0,0 +1,29 @@ +package net.dankito.utils.multiplatform + +import kotlinx.datetime.* + + +actual class DateFormatter actual constructor(pattern: String) { + + + actual constructor(dateStyle: DateFormatStyle) + : this("") + + actual constructor(dateStyle: DateFormatStyle, timeStyle: DateFormatStyle) + : this("") + + + // TODO: implement for Logger, get current time formatted as string + actual fun format(date: LocalDateTime): String { + return "" // is only used in rare cases, don't implement right now + } + + actual fun parseDate(dateString: String): LocalDate? { + return null // is only used in rare cases, don't implement right now + } + + actual fun parse(dateString: String): LocalDateTime? { + return null // is only used in rare cases, don't implement right now + } + +} \ No newline at end of file diff --git a/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/StackTraceHelper.kt b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/StackTraceHelper.kt new file mode 100644 index 00000000..a2d8fe3e --- /dev/null +++ b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/StackTraceHelper.kt @@ -0,0 +1,10 @@ +package net.dankito.utils.multiplatform + +actual class StackTraceHelper { + + actual fun getStackTrace(e: Throwable, maxCountStackTraceElements: Int?): String { + // TODO: is this a nice string? + return e.getStackTrace().take(maxCountStackTraceElements ?: Int.MAX_VALUE).joinToString("\n") + } + +} \ No newline at end of file diff --git a/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/Thread.kt b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/Thread.kt new file mode 100644 index 00000000..c081be75 --- /dev/null +++ b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/Thread.kt @@ -0,0 +1,28 @@ +package net.dankito.utils.multiplatform + + +actual class Thread { + + actual companion object { + + actual val current: Thread + get() = Thread() + + + actual fun printCurrentThreadStackTrace() { + Thread.current.printStackTrace() + } + + } + + + actual val threadName: String + get() = "main" + + + actual fun printStackTrace() { + // TODO: find a better way + Exception("Nothing happened, just to print the stack trace").printStackTrace() + } + +} \ No newline at end of file diff --git a/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/log/DefaultLoggerFactory.kt b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/log/DefaultLoggerFactory.kt new file mode 100644 index 00000000..9924f342 --- /dev/null +++ b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/log/DefaultLoggerFactory.kt @@ -0,0 +1,9 @@ +package net.dankito.utils.multiplatform.log + +actual class DefaultLoggerFactory actual constructor() { + + actual fun createDefaultLoggerFactory(): ILoggerFactory { + return LogToConsoleLoggerFactory() + } + +} \ No newline at end of file diff --git a/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/os/OsHelper.kt b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/os/OsHelper.kt new file mode 100644 index 00000000..35d173b9 --- /dev/null +++ b/multiplatform-utils/src/nativeMain/kotlin/net.dankito.utils.multiplatform/os/OsHelper.kt @@ -0,0 +1,7 @@ +package net.dankito.utils.multiplatform.os + +actual class OsHelper actual constructor() { + + actual val osType = OsType.Native + +} \ No newline at end of file