Skip to content

Commit

Permalink
Fix can not select the device correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiinaSekiu committed Aug 20, 2024
1 parent 036153f commit 50ec6bc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/main/kotlin/moe/sekiu/minilpa/lpa/LPABackend.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import moe.sekiu.minilpa.model.Profile

interface LPABackend<D : Device>
{
var selectedDevice : D?

fun set(d : D?)
{
selectedDevice = d
}

suspend fun getChipInfo() : ChipInfo

suspend fun getProfileList() : List<Profile>
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/moe/sekiu/minilpa/lpa/LPACExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class LPACExecutor() : LPABackend<Driver>
{
private val log = logger()

override var selectedDevice : Driver? = null

suspend fun getDeviceList() : List<Driver> = decode(execute("driver", "apdu", "list").data)

override suspend fun getChipInfo() : ChipInfo = decode(execute("chip", "info").data)
Expand Down Expand Up @@ -79,7 +77,7 @@ class LPACExecutor() : LPABackend<Driver>
val env = mutableMapOf<String, String>()
if (setting.debug.libeuicc.apdu) env["LIBEUICC_DEBUG_APDU"] = "true"
if (setting.debug.libeuicc.http) env["LIBEUICC_DEBUG_HTTP"] = "true"
selectedDevice?.run { env["DRIVER_IFID"] = cast<Driver>().env }
LocalProfileAssistant.devices.selectedItem?.run { env["DRIVER_IFID"] = cast<Driver>().env }
var lpacout : LPACIO? = null
process(
*(arrayOf(lpacFile.canonicalPath) + commands),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ object LocalProfileAssistant
devices.addAll(backend.cast<LPACExecutor>().getDeviceList())
val device = devices.getElementAt(0)
devices.selectedItem = device
backend.cast<LPABackend<Device>>().selectedDevice = device
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/moe/sekiu/minilpa/lpa/MiniRemoteLPA.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ suspend fun main()

class MiniRemoteLPA : LPABackend<RemoteCard>
{
override var selectedDevice : RemoteCard? = null

lateinit var wsSession : WebSocketSession
val waiting = mutableMapOf<UUID, CompletableDeferred<LPACIO>>()

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/moe/sekiu/minilpa/ui/MainFrame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import moe.sekiu.minilpa.exception.OperationFailureException
import moe.sekiu.minilpa.freeze
import moe.sekiu.minilpa.language
import moe.sekiu.minilpa.logger
import moe.sekiu.minilpa.lpa.LocalProfileAssistant
import moe.sekiu.minilpa.setup
import moe.sekiu.minilpa.setupFontSize
import moe.sekiu.minilpa.ui.component.MiniProgressDialog
Expand Down Expand Up @@ -148,7 +149,7 @@ class MainFrame : JFrame()
block : suspend () -> T
) : T?
{
if (requireDevice && backend.selectedDevice == null)
if (requireDevice && LocalProfileAssistant.devices.selectedItem == null)
{
JOptionPane.showMessageDialog(
this@MainFrame,
Expand Down

0 comments on commit 50ec6bc

Please sign in to comment.