2022-02-20 11:21:11 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Florian Schrofner
|
|
|
|
*
|
|
|
|
* 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 https://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2022-02-12 09:28:46 -05:00
|
|
|
package fi.schro.di
|
2022-02-13 11:31:48 -05:00
|
|
|
|
2022-02-16 17:10:26 -05:00
|
|
|
import fi.schro.data.ConfigurationRepository
|
|
|
|
import fi.schro.data.ConfigurationRepositoryImpl
|
2022-02-13 11:31:48 -05:00
|
|
|
import fi.schro.data.ElgatoLightRepository
|
|
|
|
import fi.schro.data.LightRepository
|
|
|
|
import fi.schro.ui.ApplyCommand
|
2022-02-20 11:09:25 -05:00
|
|
|
import fi.schro.ui.DaemonCommand
|
2022-02-13 11:31:48 -05:00
|
|
|
import fi.schro.ui.GetCommand
|
|
|
|
import fi.schro.ui.SetCommand
|
|
|
|
import io.ktor.client.*
|
|
|
|
import io.ktor.client.engine.cio.*
|
2022-02-14 15:38:34 -05:00
|
|
|
import io.ktor.client.features.json.*
|
2022-02-13 11:31:48 -05:00
|
|
|
import org.koin.dsl.module
|
|
|
|
|
|
|
|
val commandModule = module {
|
2022-02-19 11:37:09 -05:00
|
|
|
single{ ApplyCommand(get()) }
|
2022-02-20 11:09:25 -05:00
|
|
|
single{ DaemonCommand(get()) }
|
2022-02-14 16:18:58 -05:00
|
|
|
single{ SetCommand(get()) }
|
2022-02-13 11:31:48 -05:00
|
|
|
single{ GetCommand(get()) }
|
|
|
|
}
|
|
|
|
|
|
|
|
val dataModule = module {
|
2022-02-20 11:09:25 -05:00
|
|
|
single<LightRepository> { ElgatoLightRepository() }
|
2022-02-16 17:10:26 -05:00
|
|
|
single<ConfigurationRepository> { ConfigurationRepositoryImpl(get()) }
|
2022-02-13 11:31:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
val networkModule = module {
|
2022-02-20 11:09:25 -05:00
|
|
|
//HttpClient has to be recreated every time it is used
|
|
|
|
factory<HttpClient> { HttpClient(CIO){
|
2022-02-14 15:38:34 -05:00
|
|
|
install(JsonFeature)
|
|
|
|
}}
|
2022-02-13 11:31:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
val mainModule = listOf(
|
|
|
|
commandModule,
|
|
|
|
dataModule,
|
|
|
|
networkModule
|
|
|
|
)
|