diff --git a/README.md b/README.md index 99cd59b..bbe190c 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,14 @@ Start `pcscd` on systemd based distribution: `sudo systemctl start pcscd` Card reader is not connected. +## About OnlyPreview Feature + +This is an experimental feature that only previews card information without downloading it into the card. It allows for writing to other cards again. + +Some carriers, such as Tele2, do not follow the standard protocol, which may result in a "Refused" status when attempting to write to the card again. + +Please test and evaluate the risks on your own. + ## Other `SCard` error codes For complete explanation list of PCSC error codes, see [pcsc-lite: ErrorCodes](https://pcsclite.apdu.fr/api/group__ErrorCodes.html) \ No newline at end of file diff --git a/cmd.go b/cmd.go index bb45e4d..3618ca0 100644 --- a/cmd.go +++ b/cmd.go @@ -191,9 +191,20 @@ func LpacProfileDownload(info PullInfo) { if info.IMEI != "" { args = append(args, "-i", info.IMEI) } + if info.OnlyPreview == true { + args = append(args, "-p") + } _, err := runLpac(args...) if err != nil { - ShowLpacErrDialog(err) + if info.OnlyPreview == true && strings.Contains(strings.ToLower(err.Error()), "cancelled") { + // Only Preview Normally + dialogText := "Preview Download successful" + dialog.ShowInformation("Info", dialogText, WMain) + return + } else { + ShowLpacErrDialog(err) + return + } } else { notificationOrigin := Notifications Refresh() diff --git a/struct.go b/struct.go index 31f5e77..c8e8f73 100644 --- a/struct.go +++ b/struct.go @@ -12,6 +12,7 @@ type PullInfo struct { ObjectID string ConfirmCode string IMEI string + OnlyPreview bool } type LpacReturnValue struct { diff --git a/window.go b/window.go index 2f22557..42d33e6 100644 --- a/window.go +++ b/window.go @@ -218,12 +218,14 @@ func InitDownloadDialog() dialog.Dialog { matchIDEntry := &widget.Entry{PlaceHolder: "Activation code. Optional"} confirmCodeEntry := &widget.Entry{PlaceHolder: "Optional"} imeiEntry := &widget.Entry{PlaceHolder: "The IMEI sent to SM-DP+. Optional"} + onlyPreview := widget.NewCheck("Only Preview", nil) formItems := []*widget.FormItem{ {Text: "SM-DP+", Widget: smdpEntry}, {Text: "Matching ID", Widget: matchIDEntry}, {Text: "Confirm Code", Widget: confirmCodeEntry}, {Text: "IMEI", Widget: imeiEntry}, + {Text: "Only Preview", Widget: onlyPreview}, } form := widget.NewForm(formItems...) @@ -251,6 +253,7 @@ func InitDownloadDialog() dialog.Dialog { MatchID: strings.TrimSpace(matchIDEntry.Text), ConfirmCode: strings.TrimSpace(confirmCodeEntry.Text), IMEI: strings.TrimSpace(imeiEntry.Text), + OnlyPreview: onlyPreview.Checked, } go func() { err := RefreshNotification() @@ -277,7 +280,6 @@ func InitDownloadDialog() dialog.Dialog { selectQRCodeButton.Enable() pasteFromClipboardButton.Enable() } - selectQRCodeButton = &widget.Button{ Text: "Scan image file", Icon: theme.FileImageIcon(),