Skip to content

Commit ec5a436

Browse files
committed
Show success/failure using alerts
1 parent 5309d34 commit ec5a436

File tree

2 files changed

+112
-9
lines changed

2 files changed

+112
-9
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ If you have an antivirus, select "Always Allow" for anything related to tsscheck
1414
Please send feedback via [Github Issue](https://github.com/airsquared/blobsaver/issues/new) or [Reddit PM](https://www.reddit.com//message/compose?to=01110101_00101111&subject=Blobsaver+Feedback) if you encounter any bugs/problems or have a feature request.
1515

1616
## TODO:
17-
- Show success/failure using alerts
1817
- Menu bar
1918
- Choose where to save blobs
2019

src/main/java/blobsaver/Controller.java

Lines changed: 112 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,8 @@ protected Void call() throws Exception {
214214
ButtonType downloadNow = new ButtonType("Download now");
215215

216216
Alert alert = new Alert(
217-
Alert.AlertType.INFORMATION, "There is a new version available: "
218-
+ finalVersion + ". You have version " + Main.appVersion, downloadNow, ButtonType.CANCEL);
219-
alert.setHeaderText("New Update Available");
217+
Alert.AlertType.INFORMATION, "You have version " + Main.appVersion, downloadNow, ButtonType.CANCEL);
218+
alert.setHeaderText("New Update Available: " + finalVersion);
220219
Button dlButton = (Button) alert.getDialogPane().lookupButton(downloadNow);
221220
dlButton.setDefaultButton(true);
222221
alert.initModality(Modality.NONE);
@@ -319,13 +318,16 @@ private void run(String device) {
319318
}
320319
e.printStackTrace();
321320
}
321+
String tsscheckerLog;
322322
try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
323-
StringBuilder log = new StringBuilder();
323+
StringBuilder logBuilder = new StringBuilder();
324324
String line;
325325
while ((line = reader.readLine()) != null) {
326-
log.append(line).append("\n");
326+
System.out.println(line + "\n");
327+
logBuilder.append(line).append("\n");
327328
}
328-
Alert alert = new Alert(Alert.AlertType.INFORMATION, log.toString(), ButtonType.OK);
329+
tsscheckerLog = logBuilder.toString();
330+
Alert alert = new Alert(Alert.AlertType.INFORMATION, logBuilder.toString(), ButtonType.OK);
329331
alert.showAndWait();
330332
} catch (IOException e) {
331333
Alert alert = new Alert(Alert.AlertType.ERROR, "There was an error getting the tsschecker log.\n\nPlease create a new issue on Github or PM me on Reddit. The crash log has been copied to your clipboard", githubIssue, redditPM, ButtonType.CANCEL);
@@ -343,6 +345,107 @@ private void run(String device) {
343345
ee.printStackTrace();
344346
}
345347
e.printStackTrace();
348+
return;
349+
}
350+
351+
boolean resultShown = false;
352+
if (tsscheckerLog.contains("Saved shsh blobs!")) {
353+
Alert alert = new Alert(Alert.AlertType.INFORMATION, "Successfully saved blobs!", ButtonType.OK);
354+
alert.showAndWait();
355+
resultShown = true;
356+
}
357+
if (tsscheckerLog.contains("[Error] [TSSC] manually specified ecid=" + ecidField.getText() + ", but parsing failed")) {
358+
Alert alert = new Alert(Alert.AlertType.ERROR, "\"" + ecidField.getText() + "\"" + " is not a valid ECID. Try getting it from iTunes", ButtonType.OK);
359+
alert.showAndWait();
360+
resultShown = true;
361+
}
362+
if (tsscheckerLog.contains("[Error] [TSSC] device " + device + " could not be found in devicelist")) {
363+
Alert alert = new Alert(Alert.AlertType.ERROR, "tsschecker could not find device: \"" + device +
364+
"\"\n\nPlease create a new Github issue or PM me on Reddit if you used the dropdown menu", githubIssue, redditPM, ButtonType.CANCEL);
365+
alert.showAndWait();
366+
resultShown = true;
367+
try {
368+
if (alert.getResult().equals(githubIssue) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
369+
Desktop.getDesktop().browse(githubIssueURI);
370+
371+
} else if (alert.getResult().equals(redditPM) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
372+
Desktop.getDesktop().browse(redditPMURI);
373+
}
374+
} catch (IOException ee) {
375+
ee.printStackTrace();
376+
}
377+
}
378+
if (tsscheckerLog.contains("[Error] [TSSC] ERROR: could not get url for device " + device + " on iOS " + versionField.getText())) {
379+
Alert alert = new Alert(Alert.AlertType.ERROR,
380+
"Could not find device \"" + device + "\" on iOS/tvOS " + versionField.getText() +
381+
"\n\nThe version probably doesn't exist or isn't compatible with the device", ButtonType.OK);
382+
alert.showAndWait();
383+
resultShown = true;
384+
}
385+
if (tsscheckerLog.contains("[Error] [TSSC] manually specified apnonce=" + apnonceField.getText() + ", but parsing failed")) {
386+
Alert alert = new Alert(Alert.AlertType.ERROR,
387+
"\"" + apnonceField.getText() + "\" is not a valid apnonce", ButtonType.OK);
388+
alert.showAndWait();
389+
resultShown = true;
390+
}
391+
if (tsscheckerLog.contains("[WARNING] [TSSC] could not get id0 for installType=Erase. Using fallback installType=Update since user did not specify installType manually")
392+
&& tsscheckerLog.contains("[Error] [TSSR] Error: could not get id0 for installType=Update")
393+
&& tsscheckerLog.contains("[Error] [TSSR] faild to build tssrequest")
394+
&& tsscheckerLog.contains("Error] [TSSC] checking tss status failed!")) {
395+
Alert alert = new Alert(Alert.AlertType.ERROR,
396+
"Saving blobs failed. Check the board configuration.\n\nIf this doesn't work, please create a new issue on Github or PM me on Reddit. The log has been copied to your clipboard.",
397+
githubIssue, redditPM, ButtonType.OK);
398+
StringSelection stringSelection = new StringSelection(tsscheckerLog);
399+
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
400+
alert.showAndWait();
401+
resultShown = true;
402+
try {
403+
if (alert.getResult().equals(githubIssue) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
404+
Desktop.getDesktop().browse(githubIssueURI);
405+
406+
} else if (alert.getResult().equals(redditPM) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
407+
Desktop.getDesktop().browse(redditPMURI);
408+
}
409+
} catch (IOException ee) {
410+
ee.printStackTrace();
411+
}
412+
}
413+
if (tsscheckerLog.contains("[Error] ERROR: TSS request failed: Could not resolve host:")) {
414+
Alert alert = new Alert(Alert.AlertType.ERROR,
415+
"Saving blobs failed. Check your internet connection.\n\nIf your internet is working and you can connect to apple.com(in your broweser), please create a new issue on Github or PM me on Reddit. The log has been copied to your clipboard.",
416+
githubIssue, redditPM, ButtonType.OK);
417+
StringSelection stringSelection = new StringSelection(tsscheckerLog);
418+
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
419+
alert.showAndWait();
420+
resultShown = true;
421+
try {
422+
if (alert.getResult().equals(githubIssue) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
423+
Desktop.getDesktop().browse(githubIssueURI);
424+
425+
} else if (alert.getResult().equals(redditPM) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
426+
Desktop.getDesktop().browse(redditPMURI);
427+
}
428+
} catch (IOException ee) {
429+
ee.printStackTrace();
430+
}
431+
}
432+
if (tsscheckerLog.contains("[Error]") && !resultShown) {
433+
Alert alert = new Alert(Alert.AlertType.ERROR,
434+
"Saving blobs failed. Check your internet connection.\n\nPlease create a new issue on Github or PM me on Reddit. The log has been copied to your clipboard.",
435+
githubIssue, redditPM, ButtonType.OK);
436+
StringSelection stringSelection = new StringSelection(tsscheckerLog);
437+
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
438+
alert.showAndWait();
439+
try {
440+
if (alert.getResult().equals(githubIssue) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
441+
Desktop.getDesktop().browse(githubIssueURI);
442+
443+
} else if (alert.getResult().equals(redditPM) && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
444+
Desktop.getDesktop().browse(redditPMURI);
445+
}
446+
} catch (IOException ee) {
447+
ee.printStackTrace();
448+
}
346449
}
347450

348451
try {
@@ -364,6 +467,7 @@ private void run(String device) {
364467
}
365468
}
366469

470+
367471
if (!file.delete()) {
368472
Alert alert = new Alert(Alert.AlertType.ERROR, "There was an error deleting the temporary file.", githubIssue, redditPM, ButtonType.CANCEL);
369473
alert.showAndWait();
@@ -798,13 +902,13 @@ public void go() {
798902
run(identifierField.getText());
799903
} else {
800904
Alert alert = new Alert(Alert.AlertType.ERROR, "\"" + identifierText +
801-
"\" is not a valid identifier", ButtonType.OK, ButtonType.CANCEL);
905+
"\" is not a valid identifier", ButtonType.OK);
802906
alert.showAndWait();
803907
return;
804908
}
805909
} catch (StringIndexOutOfBoundsException e) {
806910
Alert alert = new Alert(Alert.AlertType.ERROR, "\"" + identifierText +
807-
"\" is not a valid identifier", ButtonType.OK, ButtonType.CANCEL);
911+
"\" is not a valid identifier", ButtonType.OK);
808912
alert.showAndWait();
809913
return;
810914
}

0 commit comments

Comments
 (0)