Refact devices apps (#135)

* refact: [CORE] device and apps

* refact: [CORE] device and apps

* refact: [CORE] device and apps

* refact: [CORE] device and apps

* refact: [CORE] device and apps

* added db files

---------

Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
Florent CHAMPIGNY 2025-08-21 22:52:15 +02:00 committed by GitHub
parent b0c8c2948b
commit 262ccfd19f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
71 changed files with 6840 additions and 345 deletions

View file

@ -1,15 +1,33 @@
package com.flocon.data.remote.device.datasource
import com.flocon.data.remote.common.safeDecodeFromString
import com.flocon.data.remote.database.models.DatabaseOutgoingQueryMessage
import com.flocon.data.remote.device.model.RegisterDeviceDataModel
import com.flocon.data.remote.models.FloconOutgoingMessageDataModel
import com.flocon.data.remote.models.toRemote
import com.flocon.data.remote.server.Server
import io.github.openflocon.data.core.device.datasource.remote.RemoteDeviceDataSource
import io.github.openflocon.domain.Protocol
import io.github.openflocon.domain.device.models.DeviceIdAndPackageNameDomainModel
import io.github.openflocon.domain.messages.models.FloconIncomingMessageDomainModel
import kotlinx.serialization.json.Json
class DeviceRemoteDataSourceImpl(
private val json: Json,
private val server: Server,
) : RemoteDeviceDataSource {
override fun getDeviceSerial(message: FloconIncomingMessageDomainModel): String? = json.safeDecodeFromString<RegisterDeviceDataModel>(message.body)
?.serial
override suspend fun askForDeviceAppIcon(deviceIdAndPackageName: DeviceIdAndPackageNameDomainModel) {
server.sendMessageToClient(
deviceIdAndPackageName = deviceIdAndPackageName.toRemote(),
message = FloconOutgoingMessageDataModel(
plugin = Protocol.ToDevice.Device.Plugin,
method = Protocol.ToDevice.Device.Method.GetAppIcon,
body = ""
),
)
}
}