From 5d3d85fa7190a70eea8fa67866c343005b9922b0 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 21 Jul 2020 10:44:32 -0300 Subject: [pos] compare version from backend and show error if incompatible --- .../main/java/net/taler/merchantpos/config/ConfigManager.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt') diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt index eee7905..a7aff18 100644 --- a/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt +++ b/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt @@ -34,14 +34,14 @@ import com.fasterxml.jackson.module.kotlin.readValue import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import net.taler.common.Version +import net.taler.common.getIncompatibleStringOrNull import net.taler.merchantlib.ConfigResponse import net.taler.merchantlib.MerchantApi import net.taler.merchantpos.LogErrorListener import net.taler.merchantpos.R import org.json.JSONObject -private const val VERSION = "0:0:0" - private const val SETTINGS_NAME = "taler-merchant-terminal" private const val SETTINGS_CONFIG_URL = "configUrl" @@ -52,6 +52,8 @@ internal const val CONFIG_URL_DEMO = "https://docs.taler.net/_static/sample-pos- internal const val CONFIG_USERNAME_DEMO = "" internal const val CONFIG_PASSWORD_DEMO = "" +private val VERSION = Version(1, 0, 0) + private val TAG = ConfigManager::class.java.simpleName interface ConfigurationReceiver { @@ -131,10 +133,9 @@ class ConfigManager( merchantConfig: MerchantConfig, configResponse: ConfigResponse ) = scope.launch(Dispatchers.Default) { - // TODO do real matching - if (VERSION != configResponse.version) { - val str = context.getString(R.string.config_error_version) - mConfigUpdateResult.postValue(ConfigUpdateResult.Error(str)) + val versionIncompatible = VERSION.getIncompatibleStringOrNull(context, configResponse.version) + if (versionIncompatible != null) { + mConfigUpdateResult.postValue(ConfigUpdateResult.Error(versionIncompatible)) return@launch } for (receiver in configurationReceivers) { -- cgit v1.2.3