mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
pySim-shell: Create + use per-RuntimeLchan SimCardCommands
This new approach will "fork" separate SimCardCommands instances for each RuntimeLchan. Higher-layer code should now always use the RuntimeLchan.scc rather than the RuntimeState.card._scc in order to make sure commands use the correct logical channel. Change-Id: I13e2e871f2afc2460d9fd1cd566de42267c7d389 Related: OS#6230
This commit is contained in:
@@ -49,7 +49,7 @@ class Ts102222Commands(CommandSet):
|
||||
self._cmd.perror("Refusing to permanently delete the file, please read the help text.")
|
||||
return
|
||||
f = self._cmd.lchan.get_file_for_selectable(opts.NAME)
|
||||
(data, sw) = self._cmd.card._scc.delete_file(f.fid)
|
||||
(data, sw) = self._cmd.lchan.scc.delete_file(f.fid)
|
||||
|
||||
def complete_delete_file(self, text, line, begidx, endidx) -> List[str]:
|
||||
"""Command Line tab completion for DELETE FILE"""
|
||||
@@ -70,7 +70,7 @@ class Ts102222Commands(CommandSet):
|
||||
self._cmd.perror("Refusing to terminate the file, please read the help text.")
|
||||
return
|
||||
f = self._cmd.lchan.get_file_for_selectable(opts.NAME)
|
||||
(data, sw) = self._cmd.card._scc.terminate_df(f.fid)
|
||||
(data, sw) = self._cmd.lchan.scc.terminate_df(f.fid)
|
||||
|
||||
def complete_terminate_df(self, text, line, begidx, endidx) -> List[str]:
|
||||
"""Command Line tab completion for TERMINATE DF"""
|
||||
@@ -86,7 +86,7 @@ class Ts102222Commands(CommandSet):
|
||||
self._cmd.perror("Refusing to terminate the file, please read the help text.")
|
||||
return
|
||||
f = self._cmd.lchan.get_file_for_selectable(opts.NAME)
|
||||
(data, sw) = self._cmd.card._scc.terminate_ef(f.fid)
|
||||
(data, sw) = self._cmd.lchan.scc.terminate_ef(f.fid)
|
||||
|
||||
def complete_terminate_ef(self, text, line, begidx, endidx) -> List[str]:
|
||||
"""Command Line tab completion for TERMINATE EF"""
|
||||
@@ -104,7 +104,7 @@ class Ts102222Commands(CommandSet):
|
||||
if not opts.force_terminate_card:
|
||||
self._cmd.perror("Refusing to permanently terminate the card, please read the help text.")
|
||||
return
|
||||
(data, sw) = self._cmd.card._scc.terminate_card_usage()
|
||||
(data, sw) = self._cmd.lchan.scc.terminate_card_usage()
|
||||
|
||||
create_parser = argparse.ArgumentParser()
|
||||
create_parser.add_argument('FILE_ID', type=str, help='File Identifier as 4-character hex string')
|
||||
@@ -149,7 +149,7 @@ class Ts102222Commands(CommandSet):
|
||||
ShortFileIdentifier(decoded=opts.short_file_id),
|
||||
]
|
||||
fcp = FcpTemplate(children=ies)
|
||||
(data, sw) = self._cmd.card._scc.create_file(b2h(fcp.to_tlv()))
|
||||
(data, sw) = self._cmd.lchan.scc.create_file(b2h(fcp.to_tlv()))
|
||||
# the newly-created file is automatically selected but our runtime state knows nothing of it
|
||||
self._cmd.lchan.select_file(self._cmd.lchan.selected_file)
|
||||
|
||||
@@ -200,7 +200,7 @@ class Ts102222Commands(CommandSet):
|
||||
}
|
||||
ies.append(ProprietaryInformation(children=[ToolkitAccessConditions(decoded=toolkit_ac)]))
|
||||
fcp = FcpTemplate(children=ies)
|
||||
(data, sw) = self._cmd.card._scc.create_file(b2h(fcp.to_tlv()))
|
||||
(data, sw) = self._cmd.lchan.scc.create_file(b2h(fcp.to_tlv()))
|
||||
# the newly-created file is automatically selected but our runtime state knows nothing of it
|
||||
self._cmd.lchan.select_file(self._cmd.lchan.selected_file)
|
||||
|
||||
@@ -217,7 +217,7 @@ class Ts102222Commands(CommandSet):
|
||||
ies = [FileIdentifier(decoded=f.fid),
|
||||
FileSize(decoded=opts.file_size)]
|
||||
fcp = FcpTemplate(children=ies)
|
||||
(data, sw) = self._cmd.card._scc.resize_file(b2h(fcp.to_tlv()))
|
||||
(data, sw) = self._cmd.lchan.scc.resize_file(b2h(fcp.to_tlv()))
|
||||
# the resized file is automatically selected but our runtime state knows nothing of it
|
||||
self._cmd.lchan.select_file(self._cmd.lchan.selected_file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user