Skip to content

Commit 1c6e847

Browse files
committed
Choose version to save blobs for, Save options for later use
1 parent cf96b0e commit 1c6e847

File tree

3 files changed

+99
-32
lines changed

3 files changed

+99
-32
lines changed

src/blobsaver/Controller.java

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@
66
import javafx.fxml.FXML;
77
import javafx.scene.control.CheckBox;
88
import javafx.scene.control.ChoiceBox;
9+
import javafx.scene.control.Label;
910
import javafx.scene.control.TextField;
1011

11-
import java.io.BufferedReader;
12-
import java.io.IOException;
13-
import java.io.InputStreamReader;
12+
import java.io.*;
13+
import java.net.URISyntaxException;
1414
import java.util.ArrayList;
1515
import java.util.Arrays;
16+
import java.util.Properties;
1617

1718
public class Controller {
1819

20+
1921
@FXML private ChoiceBox deviceTypeChoiceBox;
2022
@FXML private ChoiceBox deviceModelChoiceBox;
2123
@FXML private TextField ecidField;
2224
@FXML private TextField boardConfigField;
2325
@FXML private TextField apnonceField;
26+
@FXML private TextField versionField;
2427
@FXML private CheckBox apnonceCheckBox;
28+
@FXML private CheckBox versionCheckBox;
29+
@FXML private Label versionLabel;
2530
private boolean boardConfig = false;
2631

2732
@SuppressWarnings("unchecked")
@@ -41,15 +46,19 @@ public void initialize() {
4146
switch (v) {
4247
case "iPhone":
4348
deviceModelChoiceBox.setItems(iPhones);
49+
versionLabel.setText("iOS Version");
4450
break;
4551
case "iPod(not supported yet)":
4652
deviceModelChoiceBox.setItems(iPods);
53+
versionLabel.setText("iOS Version");
4754
break;
4855
case "iPad(not supported yet)":
4956
deviceModelChoiceBox.setItems(iPads);
57+
versionLabel.setText("iOS Version");
5058
break;
5159
case "AppleTV(not supported yet)":
5260
deviceModelChoiceBox.setItems(AppleTVs);
61+
versionLabel.setText("tvOS Version");
5362
break;
5463
}
5564
});
@@ -60,13 +69,36 @@ public void initialize() {
6069
boardConfigField.setDisable(false);
6170
} else {
6271
boardConfig = false;
72+
boardConfigField.setText("");
6373
boardConfigField.setDisable(true);
6474
}
6575
});
76+
File file;
77+
try {
78+
file = new File(getClass().getResource("options.properties").toURI());
79+
if (file.exists()) {
80+
Properties prop = new Properties();
81+
try (InputStream input = new FileInputStream(file)) {
82+
prop.load(input);
83+
ecidField.setText(prop.getProperty("ecid"));
84+
deviceTypeChoiceBox.setValue(prop.getProperty("deviceType"));
85+
deviceModelChoiceBox.setValue(prop.getProperty("deviceModel"));
86+
if (!prop.getProperty("boardConfig").equals("none")) {
87+
boardConfigField.setText(prop.getProperty("boardConfig"));
88+
}
89+
} catch (IOException e) {
90+
e.printStackTrace();
91+
}
92+
}
93+
} catch (URISyntaxException e) {
94+
e.printStackTrace();
95+
} catch (NullPointerException e) {
96+
System.out.println("No options file");
97+
}
6698
}
6799

68100
private void run(String device) {
69-
ArrayList<String> args = new ArrayList<String>(Arrays.asList(getClass().getResource("tsschecker").getPath(), "-d", device, "-i", "11.4", "-s", "-e", ecidField.getText()));
101+
ArrayList<String> args = new ArrayList<String>(Arrays.asList(getClass().getResource("tsschecker").getPath(), "-d", device, "-s", "-e", ecidField.getText()));
70102
if (boardConfig) {
71103
args.add("--boardconfig");
72104
args.add(boardConfigField.getText());
@@ -75,6 +107,12 @@ private void run(String device) {
75107
args.add("--apnonce");
76108
args.add(apnonceField.getText());
77109
}
110+
if (versionCheckBox.isSelected()) {
111+
args.add("-l");
112+
} else {
113+
args.add("-i");
114+
args.add(versionField.getText());
115+
}
78116
Process proc = null;
79117
try {
80118
proc = new ProcessBuilder(args).start();
@@ -105,6 +143,33 @@ public void apnonceCheckBoxHandler() {
105143
}
106144
}
107145

146+
public void versionCheckBoxHandler() {
147+
if (versionCheckBox.isSelected()) {
148+
versionField.setDisable(true);
149+
} else {
150+
versionField.setDisable(false);
151+
}
152+
}
153+
154+
public void saveOptions() {
155+
Properties prop = new Properties();
156+
File file = new File(getClass().getResource("").toString().substring(5), "options.properties");
157+
try (OutputStream output = new FileOutputStream(file)) {
158+
prop.setProperty("ecid", ecidField.getText());
159+
prop.setProperty("deviceType", (String) deviceTypeChoiceBox.getValue());
160+
prop.setProperty("deviceModel", (String) deviceModelChoiceBox.getValue());
161+
if (boardConfig) {
162+
prop.setProperty("boardConfig", boardConfigField.getText());
163+
} else {
164+
prop.setProperty("boardConfig", "none");
165+
}
166+
prop.store(output, null);
167+
} catch (IOException e) {
168+
e.printStackTrace();
169+
}
170+
171+
}
172+
108173

109174
public void go() {
110175
if (ecidField.getText().equals("") || deviceModelChoiceBox.getValue().equals("") || (boardConfig && boardConfigField.getText().equals("")) || (apnonceCheckBox.isSelected() && apnonceField.getText().equals(""))) {

src/blobsaver/Main.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88

99
public class Main extends Application {
1010

11+
public static void main(String[] args) {
12+
launch(args);
13+
}
14+
1115
@Override
12-
public void start(Stage primaryStage) throws Exception{
16+
public void start(Stage primaryStage) throws Exception {
1317
Parent root = FXMLLoader.load(getClass().getResource("blobsaver.fxml"));
1418
primaryStage.setTitle("SHSH Blob Saver");
1519
primaryStage.setScene(new Scene(root, 300, 275));
1620
primaryStage.show();
1721
}
18-
19-
20-
public static void main(String[] args) {
21-
launch(args);
22-
}
2322
}

src/blobsaver/blobsaver.fxml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@
33
<?import javafx.scene.control.*?>
44
<?import javafx.scene.layout.HBox?>
55
<?import javafx.scene.layout.VBox?>
6-
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="blobsaver.Controller">
7-
<children>
8-
<Label text="ECID:" />
9-
<HBox prefHeight="100.0" prefWidth="200.0">
10-
<children>
11-
<TextField fx:id="ecidField" />
12-
</children>
13-
</HBox>
14-
<Label text="Device" />
15-
<HBox prefHeight="100.0" prefWidth="200.0">
16-
<children>
17-
<ChoiceBox fx:id="deviceTypeChoiceBox" prefWidth="150.0" />
18-
<ChoiceBox fx:id="deviceModelChoiceBox" prefWidth="150.0" />
19-
</children>
20-
</HBox>
21-
<Label text="Internal Name/Board Configuration:" />
22-
<TextField fx:id="boardConfigField" disable="true"/>
23-
<CheckBox fx:id="apnonceCheckBox" mnemonicParsing="false" text="Manually specify apnonce:"
24-
onAction="#apnonceCheckBoxHandler"/>
25-
<TextField fx:id="apnonceField" disable="true"/>
26-
<Button mnemonicParsing="false" text="Go" onAction="#go"/>
27-
</children>
6+
<VBox xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
7+
minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8"
8+
fx:controller="blobsaver.Controller">
9+
<Label text="ECID:"/>
10+
<HBox prefHeight="100.0" prefWidth="200.0">
11+
<TextField fx:id="ecidField"/>
12+
</HBox>
13+
<Label text="Device"/>
14+
<HBox prefHeight="100.0" prefWidth="200.0">
15+
<ChoiceBox fx:id="deviceTypeChoiceBox" prefWidth="150.0"/>
16+
<ChoiceBox fx:id="deviceModelChoiceBox" prefWidth="150.0"/>
17+
</HBox>
18+
<Label fx:id="versionLabel" text="Version"/>
19+
<CheckBox fx:id="versionCheckBox" mnemonicParsing="false" onAction="#versionCheckBoxHandler" selected="true"
20+
text="Use Latest Version"/>
21+
<TextField fx:id="versionField" disable="true"/>
22+
<Label text="Internal Name/Board Configuration:"/>
23+
<TextField fx:id="boardConfigField" disable="true"/>
24+
<CheckBox fx:id="apnonceCheckBox" mnemonicParsing="false" onAction="#apnonceCheckBoxHandler"
25+
text="Manually specify apnonce:"/>
26+
<TextField fx:id="apnonceField" disable="true"/>
27+
<HBox prefHeight="100.0" prefWidth="200.0">
28+
<Button mnemonicParsing="false" onAction="#go" text="Go"/>
29+
<Button mnemonicParsing="false" text="Save options" onAction="#saveOptions"/>
30+
</HBox>
2831
</VBox>

0 commit comments

Comments
 (0)