introduce "device confirmed" when device is plugged

This commit is contained in:
l_samenv
2023-09-14 10:58:52 +02:00
parent 298ba9e030
commit 62f4f08d5f
3 changed files with 69 additions and 35 deletions

View File

@ -177,10 +177,12 @@ proc get_param_values {hp} {
}
proc check_or_do {doit service cfgs} {
# result: 1: no change needed, 0: change needed, 2: failure
set result 1
set config ""
set stick ""
set addons [list]
foreach cfg $cfgs {
if {[regexp {(.*)\.addon} $cfg -> addon]} {
if {![addon_list exists $addon]} {
@ -195,10 +197,20 @@ proc check_or_do {doit service cfgs} {
device makeitem frappy_u_config 1
if {$config ne [hval /device/name]} {
if {$doit} {
if {[hval /device/confirmed] eq [hval /device/name]} {
set msg "do not allow frappy to change from [hval /device/name] to $config"
clientlog $msg
return $msg
}
clientlog 0
clientlog TRANSACTIONFINISHED
samenv -q $config
} else {
device makeitem frappy_u_config 0
}
if {[hval /device/name] == "none"} {
return none
}
set result 0
}
}
@ -206,15 +218,22 @@ proc check_or_do {doit service cfgs} {
device makeitem frappy_u_stick 1
if {$stick ne [hval /device/stick_name]} {
if {$doit} {
clientlog 0
clientlog TRANSACTIONFINISHED
addon stick $stick
} else {
device makeitem frappy_u_stick 0
}
if {[hval /device/name] == "none"} {
return nonestick
}
set result 0
}
}
foreach addon $addons {
if {$doit} {
clientlog 0
clientlog TRANSACTIONFINISHED
addon $addon
} else {
device makeitem frappy_u_addon 0