Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ${Name} as variable for save path (CLI only) #623

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/airsquared/blobsaver/app/Background.java
Expand Up @@ -280,7 +280,8 @@ public static void saveAllBackgroundBlobs() {
}

public static void saveBlobs(Prefs.SavedDevice savedDevice) {
TSS.Builder builder = new TSS.Builder().setDevice(savedDevice.getIdentifier())
TSS.Builder builder = new TSS.Builder().setName(savedDevice.getName())
.setDevice(savedDevice.getIdentifier())
.setEcid(savedDevice.getEcid()).setSavePath(savedDevice.getSavePath())
.setIncludeBetas(savedDevice.doesIncludeBetas());
savedDevice.getBoardConfig().ifPresent(builder::setBoardConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/airsquared/blobsaver/app/CLI.java
Expand Up @@ -93,7 +93,7 @@ static class BackgroundControls {

@Option(names = "--save-path", paramLabel = "<path>",
description = "Directory to save blobs in. Can use the following variables: " +
"$${DeviceIdentifier}, $${BoardConfig}, $${APNonce}, $${Generator}, $${DeviceModel}, $${ECID}, $${FullVersionString}, $${BuildID}, and $${MajorVersion}.")
"$${DeviceIdentifier}, $${BoardConfig}, $${APNonce}, $${Generator}, $${DeviceModel}, $${ECID}, $${FullVersionString}, $${BuildID}, $${MajorVersion} and $${Name} (if using a saved device).")
File savePath;

@ArgGroup
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/airsquared/blobsaver/app/Controller.java
Expand Up @@ -57,6 +57,7 @@ public class Controller {

@FXML private TextField ecidField, boardConfigField, apnonceField, generatorField, versionField, identifierField,
pathField, ipswField;
private String deviceName;

@FXML private CheckBox apnonceCheckBox, allSignedVersionsCheckBox, identifierCheckBox, betaCheckBox,
manualURLCheckBox, saveToTSSSaverCheckBox, saveToSHSHHostCheckBox;
Expand Down Expand Up @@ -204,6 +205,7 @@ private void loadSavedDevice(Prefs.SavedDevice savedDevice) {
}
deleteDeviceMenu.setText("Remove \"" + savedDevice + "\"");

deviceName = savedDevice.getName();
ecidField.setText(savedDevice.getEcid());
pathField.setText(savedDevice.getSavePath());
if (!betaCheckBox.isDisabled()) {
Expand Down Expand Up @@ -324,7 +326,8 @@ public void checkBlobs() {
public void locationHelp() {
ButtonType openURL = new ButtonType("Open URL");
Alert alert = new Alert(Alert.AlertType.INFORMATION,
"You can use the following variables which will be automatically replaced by their respective values: ${DeviceIdentifier}, ${BoardConfig}, ${APNonce}, ${Generator}, ${DeviceModel}, ${ECID}, ${FullVersionString}, ${BuildID}, and ${MajorVersion}." +
"You can use the following variables which will be automatically replaced by their respective values: ${DeviceIdentifier}, ${BoardConfig}, ${APNonce}, ${Generator}, ${DeviceModel}, ${ECID}, ${FullVersionString}, ${BuildID} and ${MajorVersion}." +
"\nIf using a saved device you can also use ${Name}." +
"\n\nExamples: /Users/airsquared/Blobs/${DeviceModel}/${MajorVersion}" +
"\n/Users/airsquared/Blobs/${DeviceIdentifier}/${MajorVersion}/${FullVersionString}\n\n" +
"Click \"Open URL\" to see how to automatically upload blobs you save to the cloud.", openURL, ButtonType.OK);
Expand Down Expand Up @@ -655,12 +658,20 @@ private boolean checkInputs() {

private TSS createTSS(String runningAlertTitle) {
TSS.Builder builder = new TSS.Builder()
.setName(deviceName)
.setDevice(identifierCheckBox.isSelected() ?
identifierField.getText() : Devices.modelToIdentifier(deviceModelChoiceBox.getValue()))
.setEcid(ecidField.getText()).setSavePath(pathField.getText())
.setIncludeBetas(betaCheckBox.isSelected())
.saveToTSSSaver(saveToTSSSaverCheckBox.isSelected())
.saveToSHSHHost(saveToSHSHHostCheckBox.isSelected());
if (pathField.getText().contains("${Name}") && deviceName == null) {
final Alert deviceNameAlert = new Alert(Alert.AlertType.WARNING);
deviceNameAlert.setTitle("Warning");
deviceNameAlert.setHeaderText("Warning");
deviceNameAlert.setContentText("You are using ${Name} variable but your device does not have a name yet. Maybe you forgot to save it or did not select it in the list first?");
deviceNameAlert.showAndWait();
}
if (!boardConfigField.isDisabled()) {
builder.setBoardConfig(boardConfigField.getText());
}
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/airsquared/blobsaver/app/TSS.java
Expand Up @@ -51,6 +51,7 @@ public class TSS extends Task<String> {
private static final Pattern ipswURLPattern = Pattern.compile("(https?://|file:/).*\\.(ipsw|plist)");
private static final Pattern versionPattern = Pattern.compile("[0-9]+\\.[0-9]+\\.?[0-9]*(?<!\\.)");

private final String name;
private final String deviceIdentifier;
private final String ecid;
private final String savePath;
Expand All @@ -68,7 +69,8 @@ public class TSS extends Task<String> {
/**
* Private constructor; use {@link TSS.Builder} instead
*/
private TSS(String deviceIdentifier, String ecid, String savePath, String boardConfig, boolean includeBetas, String manualVersion, String manualIpswURL, String apnonce, String generator, boolean saveToTSSSaver, boolean saveToSHSHHost) {
private TSS(String name, String deviceIdentifier, String ecid, String savePath, String boardConfig, boolean includeBetas, String manualVersion, String manualIpswURL, String apnonce, String generator, boolean saveToTSSSaver, boolean saveToSHSHHost) {
this.name = name;
this.deviceIdentifier = deviceIdentifier;
this.ecid = ecid;
this.boardConfig = boardConfig;
Expand Down Expand Up @@ -189,7 +191,8 @@ private String parsePath(String input) {
if (!input.contains("${")) return input;
String template = input;

var variables = Map.of("${DeviceIdentifier}", deviceIdentifier,
var variables = Map.of("${Name}", Utils.defIfNull(name, "UnknownName"),
"${DeviceIdentifier}", deviceIdentifier,
"${BoardConfig}", getBoardConfig(),
"${APNonce}", Utils.defIfNull(apnonce, "UnknownAPNonce"),
"${Generator}", Utils.defIfNull(generator, "UnknownGenerator"),
Expand Down Expand Up @@ -382,9 +385,13 @@ && containsIgnoreCase(tsscheckerLog, "checking tss status failed")) {

@SuppressWarnings("UnusedReturnValue")
public static class Builder {
private String device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
private String name, device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
private boolean includeBetas, saveToTSSSaver, saveToSHSHHost;

public Builder setName(String name) {
this.name = name;
return this;
}
public Builder setDevice(String device) {
this.device = device;
return this;
Expand Down Expand Up @@ -443,7 +450,8 @@ public Builder saveToSHSHHost(boolean saveToSHSHHost) {
}

public TSS build() {
return new TSS(Objects.requireNonNull(device, "Device"),
return new TSS(name,
Objects.requireNonNull(device, "Device"),
Objects.requireNonNull(ecid, "ECID"),
Objects.requireNonNull(savePath, "Save Path"),
boardConfig, includeBetas, manualVersion, manualIpswURL, apnonce, generator, saveToTSSSaver, saveToSHSHHost);
Expand Down