Refactor some old UI-related code. Rewrite LogPrinter to handle commandline. Add RCM-payload module into CLI interface: now it could be executed on system without graphical environment (x86/amd64 only).
E.g.: java -jar app.jar --rcm payload.bin
This commit is contained in:
parent
255c926184
commit
6b65c74c9d
23 changed files with 328 additions and 154 deletions
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
|||
<name>NS-USBloader</name>
|
||||
|
||||
<artifactId>ns-usbloader</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
|
||||
<url>https://github.com/developersu/ns-usbloader/</url>
|
||||
<description>
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
package nsusbloader.COM.NET;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.Log;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import nsusbloader.COM.Helpers.NSSplitReader;
|
||||
|
@ -33,7 +34,7 @@ import java.util.*;
|
|||
|
||||
public class NETCommunications extends Task<Void> { // todo: thows IOException?
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
|
||||
private String hostIP;
|
||||
private int hostPort;
|
||||
|
@ -61,7 +62,7 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
|
|||
else
|
||||
this.extras = "";
|
||||
this.switchIP = switchIP;
|
||||
this.logPrinter = new LogPrinter(EModule.USB_NET_TRANSFERS);
|
||||
this.logPrinter = Log.getPrinter(EModule.USB_NET_TRANSFERS);
|
||||
this.nspMap = new HashMap<>();
|
||||
this.nspFileSizes = new HashMap<>();
|
||||
// Filter and remove empty/incorrect split-files
|
||||
|
|
|
@ -22,7 +22,7 @@ import javafx.application.Platform;
|
|||
import javafx.concurrent.Task;
|
||||
import javafx.stage.FileChooser;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import nsusbloader.COM.Helpers.NSSplitReader;
|
||||
import org.usb4java.DeviceHandle;
|
||||
|
@ -69,7 +69,7 @@ class GoldLeaf extends TransferModule {
|
|||
// For using in CMD_SelectFile with SPEC:/ prefix
|
||||
private File selectedFile;
|
||||
|
||||
GoldLeaf(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, LogPrinter logPrinter, boolean nspFilter){
|
||||
GoldLeaf(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, ILogPrinter logPrinter, boolean nspFilter){
|
||||
super(handler, nspMap, task, logPrinter);
|
||||
|
||||
final byte CMD_GetDriveCount = 1;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package nsusbloader.COM.USB;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import nsusbloader.COM.Helpers.NSSplitReader;
|
||||
|
@ -53,7 +53,7 @@ public class GoldLeaf_05 extends TransferModule {
|
|||
private RandomAccessFile raf; // NSP File
|
||||
private NSSplitReader nsr; // It'a also NSP File
|
||||
|
||||
GoldLeaf_05(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, LogPrinter logPrinter){
|
||||
GoldLeaf_05(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, ILogPrinter logPrinter){
|
||||
super(handler, nspMap, task, logPrinter);
|
||||
status = EFileStatus.FAILED;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import javafx.concurrent.Task;
|
|||
import javafx.stage.FileChooser;
|
||||
import nsusbloader.COM.Helpers.NSSplitReader;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import org.usb4java.DeviceHandle;
|
||||
import org.usb4java.LibUsb;
|
||||
|
@ -69,7 +69,7 @@ class GoldLeaf_07 extends TransferModule {
|
|||
// For using in CMD_SelectFile with SPEC:/ prefix
|
||||
private File selectedFile;
|
||||
|
||||
GoldLeaf_07(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, LogPrinter logPrinter, boolean nspFilter){
|
||||
GoldLeaf_07(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, ILogPrinter logPrinter, boolean nspFilter){
|
||||
super(handler, nspMap, task, logPrinter);
|
||||
|
||||
final byte CMD_GetDriveCount = 0x00;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package nsusbloader.COM.USB.PFS;
|
||||
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -38,7 +38,7 @@ public class PFSProvider {
|
|||
private long bodySize;
|
||||
private int ticketID = -1;
|
||||
|
||||
public PFSProvider(File nspFile, LogPrinter logPrinter) throws Exception{
|
||||
public PFSProvider(File nspFile, ILogPrinter logPrinter) throws Exception{
|
||||
if (nspFile.isDirectory()) {
|
||||
nspFileName = nspFile.getName();
|
||||
nspFile = new File(nspFile.getAbsolutePath() + File.separator + "00");
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package nsusbloader.COM.USB;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import nsusbloader.COM.Helpers.NSSplitReader;
|
||||
|
@ -48,7 +48,7 @@ class TinFoil extends TransferModule {
|
|||
/* byte[] magic = new byte[4];
|
||||
ByteBuffer bb = StandardCharsets.UTF_8.encode("TUC0").rewind().get(magic); // Let's rephrase this 'string' */
|
||||
|
||||
TinFoil(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, LogPrinter logPrinter){
|
||||
TinFoil(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, ILogPrinter logPrinter){
|
||||
super(handler, nspMap, task, logPrinter);
|
||||
logPrinter.print("============= Tinfoil =============", EMsgType.INFO);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package nsusbloader.COM.USB;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import org.usb4java.DeviceHandle;
|
||||
|
@ -31,11 +31,11 @@ public abstract class TransferModule {
|
|||
EFileStatus status = EFileStatus.UNKNOWN;
|
||||
|
||||
LinkedHashMap<String, File> nspMap;
|
||||
LogPrinter logPrinter;
|
||||
ILogPrinter logPrinter;
|
||||
DeviceHandle handlerNS;
|
||||
Task<Void> task;
|
||||
|
||||
TransferModule(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, LogPrinter printer){
|
||||
TransferModule(DeviceHandle handler, LinkedHashMap<String, File> nspMap, Task<Void> task, ILogPrinter printer){
|
||||
this.handlerNS = handler;
|
||||
this.nspMap = nspMap;
|
||||
this.task = task;
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
package nsusbloader.COM.USB;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.ModelControllers.Log;
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
|
@ -32,7 +33,7 @@ import java.util.*;
|
|||
// TODO: add filter option to show only NSP files
|
||||
public class UsbCommunications extends Task<Void> {
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
private LinkedHashMap<String, File> nspMap;
|
||||
private String protocol;
|
||||
private boolean nspFilterForGl;
|
||||
|
@ -43,7 +44,7 @@ public class UsbCommunications extends Task<Void> {
|
|||
this.nspMap = new LinkedHashMap<>();
|
||||
for (File f: nspList)
|
||||
nspMap.put(f.getName(), f);
|
||||
this.logPrinter = new LogPrinter(EModule.USB_NET_TRANSFERS);
|
||||
this.logPrinter = Log.getPrinter(EModule.USB_NET_TRANSFERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package nsusbloader.COM.USB;
|
||||
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import org.usb4java.*;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class UsbConnect {
|
|||
private DeviceHandle handlerNS;
|
||||
private Device deviceNS;
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
|
||||
private boolean connected; // TODO: replace to 'connectionFailure' and invert requests everywhere
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class UsbConnect {
|
|||
private int returningValue;
|
||||
private DeviceList deviceList;
|
||||
|
||||
public static UsbConnect connectRcmMode(LogPrinter logPrinter){
|
||||
public static UsbConnect connectRcmMode(ILogPrinter logPrinter){
|
||||
UsbConnect usbConnect = new UsbConnect(logPrinter);
|
||||
usbConnect.VENDOR_ID = RCM_VID;
|
||||
usbConnect.PRODUCT_ID = RCM_PID;
|
||||
|
@ -71,7 +71,7 @@ public class UsbConnect {
|
|||
|
||||
return usbConnect;
|
||||
}
|
||||
public static UsbConnect connectHomebrewMode(LogPrinter logPrinter){
|
||||
public static UsbConnect connectHomebrewMode(ILogPrinter logPrinter){
|
||||
UsbConnect usbConnect = new UsbConnect(logPrinter);
|
||||
usbConnect.VENDOR_ID = HOMEBREW_VID;
|
||||
usbConnect.PRODUCT_ID = HOMEBREW_PID;
|
||||
|
@ -96,7 +96,7 @@ public class UsbConnect {
|
|||
|
||||
private UsbConnect(){}
|
||||
|
||||
private UsbConnect(LogPrinter logPrinter){
|
||||
private UsbConnect(ILogPrinter logPrinter){
|
||||
this.logPrinter = logPrinter;
|
||||
this.connected = false;
|
||||
};
|
||||
|
|
|
@ -89,10 +89,7 @@ public class FrontController implements Initializable {
|
|||
}
|
||||
}
|
||||
// Really bad disable-enable upload button function
|
||||
if (tableFilesListController.isFilesForUploadListEmpty())
|
||||
disableUploadStopBtn(true);
|
||||
else
|
||||
disableUploadStopBtn(false);
|
||||
disableUploadStopBtn(tableFilesListController.isFilesForUploadListEmpty());
|
||||
}); // Add listener to notify tableView controller
|
||||
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // Notify tableView controller
|
||||
|
||||
|
@ -132,10 +129,7 @@ public class FrontController implements Initializable {
|
|||
this.switchThemeBtn.setOnAction(e->switchTheme());
|
||||
|
||||
|
||||
if (getSelectedProtocol().equals("TinFoil"))
|
||||
uploadStopBtn.setDisable(true);
|
||||
else
|
||||
uploadStopBtn.setDisable(false);
|
||||
uploadStopBtn.setDisable(getSelectedProtocol().equals("TinFoil"));
|
||||
selectNspBtn.setOnAction(e-> selectFilesBtnAction());
|
||||
|
||||
selectSplitNspBtn.setOnAction(e-> selectSplitBtnAction());
|
||||
|
@ -157,15 +151,19 @@ public class FrontController implements Initializable {
|
|||
* Changes UI theme on the go
|
||||
* */
|
||||
private void switchTheme(){
|
||||
if (switchThemeBtn.getScene().getStylesheets().get(0).equals("/res/app_dark.css")) {
|
||||
switchThemeBtn.getScene().getStylesheets().remove("/res/app_dark.css");
|
||||
switchThemeBtn.getScene().getStylesheets().add("/res/app_light.css");
|
||||
final String darkTheme = "/res/app_dark.css";
|
||||
final String lightTheme = "/res/app_light.css";
|
||||
final ObservableList<String> styleSheets = switchThemeBtn.getScene().getStylesheets();
|
||||
|
||||
if (styleSheets.get(0).equals(darkTheme)) {
|
||||
styleSheets.remove(darkTheme);
|
||||
styleSheets.add(lightTheme);
|
||||
}
|
||||
else {
|
||||
switchThemeBtn.getScene().getStylesheets().remove("/res/app_light.css");
|
||||
switchThemeBtn.getScene().getStylesheets().add("/res/app_dark.css");
|
||||
styleSheets.remove(lightTheme);
|
||||
styleSheets.add(darkTheme);
|
||||
}
|
||||
AppPreferences.getInstance().setTheme(switchThemeBtn.getScene().getStylesheets().get(0));
|
||||
AppPreferences.getInstance().setTheme(styleSheets.get(0));
|
||||
}
|
||||
/**
|
||||
* Get selected protocol (GL/TF)
|
||||
|
@ -186,8 +184,6 @@ public class FrontController implements Initializable {
|
|||
return nsIpTextField.getText();
|
||||
}
|
||||
|
||||
|
||||
/*-****************************************************************************************************************-*/
|
||||
/**
|
||||
* Functionality for selecting NSP button.
|
||||
* */
|
||||
|
@ -244,59 +240,60 @@ public class FrontController implements Initializable {
|
|||
* It's button listener when no transmission executes
|
||||
* */
|
||||
private void uploadBtnAction(){
|
||||
if ((workThread == null || !workThread.isAlive())){
|
||||
if (workThread != null && workThread.isAlive())
|
||||
return;
|
||||
|
||||
// Collect files
|
||||
List<File> nspToUpload;
|
||||
if (tableFilesListController.getFilesForUpload() == null && getSelectedProtocol().equals("TinFoil")) {
|
||||
MediatorControl.getInstance().getContoller().logArea.setText(resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected"));
|
||||
|
||||
TextArea logArea = MediatorControl.getInstance().getContoller().logArea;
|
||||
|
||||
if (getSelectedProtocol().equals("TinFoil") && tableFilesListController.getFilesForUpload() == null) {
|
||||
logArea.setText(resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected"));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
if ((nspToUpload = tableFilesListController.getFilesForUpload()) != null){
|
||||
MediatorControl.getInstance().getContoller().logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\n");
|
||||
for (File item: nspToUpload)
|
||||
MediatorControl.getInstance().getContoller().logArea.appendText(" "+item.getAbsolutePath()+"\n");
|
||||
logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\n");
|
||||
nspToUpload.forEach(item -> logArea.appendText(" "+item.getAbsolutePath()+"\n"));
|
||||
}
|
||||
else {
|
||||
MediatorControl.getInstance().getContoller().logArea.clear();
|
||||
logArea.clear();
|
||||
nspToUpload = new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
SettingsController settings = MediatorControl.getInstance().getContoller().getSettingsCtrlr();
|
||||
// If USB selected
|
||||
if (getSelectedProtocol().equals("GoldLeaf") ||
|
||||
( getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("USB") )
|
||||
){
|
||||
usbNetCommunications = new UsbCommunications(nspToUpload, getSelectedProtocol()+MediatorControl.getInstance().getContoller().getSettingsCtrlr().getGlOldVer(), MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL());
|
||||
workThread = new Thread(usbNetCommunications);
|
||||
workThread.setDaemon(true);
|
||||
workThread.start();
|
||||
if (getSelectedProtocol().equals("GoldLeaf") || ( getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("USB") ) ){
|
||||
usbNetCommunications = new UsbCommunications(nspToUpload, getSelectedProtocol() + settings.getGlOldVer(), settings.getNSPFileFilterForGL());
|
||||
}
|
||||
else { // NET INSTALL OVER TINFOIL
|
||||
if (MediatorControl.getInstance().getContoller().getSettingsCtrlr().isNsIpValidate() && ! getNsIp().matches("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"))
|
||||
if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"),resourceBundle.getString("windowBodyBadIp")))
|
||||
final String ipValidationPattern = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
|
||||
|
||||
if (settings.isNsIpValidate() && ! getNsIp().matches(ipValidationPattern)) {
|
||||
if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"), resourceBundle.getString("windowBodyBadIp")))
|
||||
return;
|
||||
}
|
||||
|
||||
String nsIP = getNsIp();
|
||||
|
||||
if (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getExpertModeSelected())
|
||||
if (! settings.getExpertModeSelected())
|
||||
usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", "");
|
||||
else {
|
||||
usbNetCommunications = new NETCommunications(
|
||||
nspToUpload,
|
||||
nsIP,
|
||||
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNotServeSelected(),
|
||||
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getAutoIpSelected()?"":MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostIp(),
|
||||
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getRandPortSelected()?"":MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostPort(),
|
||||
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNotServeSelected()?MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostExtra():""
|
||||
settings.getNotServeSelected(),
|
||||
settings.getAutoIpSelected()?"":settings.getHostIp(),
|
||||
settings.getRandPortSelected()?"":settings.getHostPort(),
|
||||
settings.getNotServeSelected()?settings.getHostExtra():""
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
workThread = new Thread(usbNetCommunications);
|
||||
workThread.setDaemon(true);
|
||||
workThread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* It's button listener when transmission in progress
|
||||
* */
|
||||
|
@ -320,10 +317,11 @@ public class FrontController implements Initializable {
|
|||
@FXML
|
||||
private void handleDrop(DragEvent event){
|
||||
List<File> filesDropped = event.getDragboard().getFiles();
|
||||
SettingsController settingsController = MediatorControl.getInstance().getContoller().getSettingsCtrlr();
|
||||
|
||||
if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTfXciNszXczSupport())
|
||||
if (getSelectedProtocol().equals("TinFoil") && settingsController.getTfXciNszXczSupport())
|
||||
filesDropped.removeIf(file -> ! file.getName().toLowerCase().matches("(.*\\.nsp$)|(.*\\.xci$)|(.*\\.nsz$)|(.*\\.xcz$)"));
|
||||
else if (getSelectedProtocol().equals("GoldLeaf") && (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL()))
|
||||
else if (getSelectedProtocol().equals("GoldLeaf") && (! settingsController.getNSPFileFilterForGL()))
|
||||
filesDropped.removeIf(file -> (file.isDirectory() && ! file.getName().toLowerCase().matches(".*\\.nsp$")));
|
||||
else
|
||||
filesDropped.removeIf(file -> ! file.getName().toLowerCase().matches(".*\\.nsp$"));
|
||||
|
@ -339,7 +337,7 @@ public class FrontController implements Initializable {
|
|||
* Called from mediator
|
||||
* TODO: remove shitcoding practices
|
||||
* */
|
||||
public void notifyTransmThreadStarted(boolean isActive, EModule type){
|
||||
public void notifyThreadStarted(boolean isActive, EModule type){
|
||||
if (! type.equals(EModule.USB_NET_TRANSFERS)){
|
||||
usbNetPane.setDisable(isActive);
|
||||
return;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package nsusbloader.Controllers;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
|
@ -36,7 +35,7 @@ import nsusbloader.AppPreferences;
|
|||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.ServiceWindow;
|
||||
import nsusbloader.Utilities.RcmTask;
|
||||
import nsusbloader.Utilities.Rcm;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
@ -199,37 +198,32 @@ public class RcmController implements Initializable {
|
|||
return;
|
||||
}
|
||||
|
||||
Task<Boolean> RcmTask;
|
||||
Rcm rcmTask;
|
||||
RadioButton selectedRadio = (RadioButton)rcmToggleGrp.getSelectedToggle();
|
||||
switch (selectedRadio.getId()){
|
||||
case "pldrRadio1":
|
||||
RcmTask = new RcmTask(payloadFPathLbl1.getText());
|
||||
rcmTask = new Rcm(payloadFPathLbl1.getText());
|
||||
break;
|
||||
case "pldrRadio2":
|
||||
RcmTask = new RcmTask(payloadFPathLbl2.getText());
|
||||
rcmTask = new Rcm(payloadFPathLbl2.getText());
|
||||
break;
|
||||
case "pldrRadio3":
|
||||
RcmTask = new RcmTask(payloadFPathLbl3.getText());
|
||||
rcmTask = new Rcm(payloadFPathLbl3.getText());
|
||||
break;
|
||||
case "pldrRadio4":
|
||||
RcmTask = new RcmTask(payloadFPathLbl4.getText());
|
||||
rcmTask = new Rcm(payloadFPathLbl4.getText());
|
||||
break;
|
||||
case "pldrRadio5":
|
||||
RcmTask = new RcmTask(payloadFPathLbl5.getText());
|
||||
rcmTask = new Rcm(payloadFPathLbl5.getText());
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
RcmTask.setOnSucceeded(event -> {
|
||||
if (RcmTask.getValue())
|
||||
statusLbl.setText(rb.getString("done_txt"));
|
||||
else
|
||||
statusLbl.setText(rb.getString("failure_txt"));
|
||||
});
|
||||
Thread RcmThread = new Thread(RcmTask);
|
||||
RcmThread.setDaemon(true);
|
||||
RcmThread.start();
|
||||
Thread rcmThread = new Thread(rcmTask);
|
||||
|
||||
rcmThread.setDaemon(true);
|
||||
rcmThread.start();
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -328,7 +322,14 @@ public class RcmController implements Initializable {
|
|||
}
|
||||
}
|
||||
|
||||
public void notifySmThreadStarted(boolean isStart, EModule type){
|
||||
public void setOneLineStatus(boolean statusSuccess){
|
||||
if (statusSuccess)
|
||||
statusLbl.setText(rb.getString("done_txt"));
|
||||
else
|
||||
statusLbl.setText(rb.getString("failure_txt"));
|
||||
}
|
||||
|
||||
public void notifyThreadStarted(boolean isStart, EModule type){
|
||||
rcmToolPane.setDisable(isStart);
|
||||
if (type.equals(EModule.RCM) && isStart){
|
||||
MediatorControl.getInstance().getContoller().logArea.clear();
|
||||
|
|
|
@ -41,9 +41,9 @@ public class MediatorControl {
|
|||
|
||||
public synchronized void setBgThreadActive(boolean isActive, EModule appModuleType) {
|
||||
isTransferActive.set(isActive);
|
||||
mainCtrler.getFrontCtrlr().notifyTransmThreadStarted(isActive, appModuleType);
|
||||
mainCtrler.getFrontCtrlr().notifyThreadStarted(isActive, appModuleType);
|
||||
mainCtrler.getSmCtrlr().notifySmThreadStarted(isActive, appModuleType);
|
||||
mainCtrler.getRcmCtrlr().notifySmThreadStarted(isActive, appModuleType);
|
||||
mainCtrler.getRcmCtrlr().notifyThreadStarted(isActive, appModuleType);
|
||||
mainCtrler.getNXDTabController().notifyThreadStarted(isActive, appModuleType);
|
||||
}
|
||||
public synchronized boolean getTransferActive() { return this.isTransferActive.get(); }
|
||||
|
|
35
src/main/java/nsusbloader/ModelControllers/ILogPrinter.java
Normal file
35
src/main/java/nsusbloader/ModelControllers/ILogPrinter.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright 2019-2020 Dmitry Isaenko
|
||||
|
||||
This file is part of NS-USBloader.
|
||||
|
||||
NS-USBloader is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
NS-USBloader is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with NS-USBloader. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package nsusbloader.ModelControllers;
|
||||
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface ILogPrinter {
|
||||
void print(String message, EMsgType type);
|
||||
void updateProgress(Double value);
|
||||
void update(HashMap<String, File> nspMap, EFileStatus status);
|
||||
void update(File file, EFileStatus status);
|
||||
void updateOneLinerStatus(boolean status);
|
||||
void close();
|
||||
}
|
34
src/main/java/nsusbloader/ModelControllers/Log.java
Normal file
34
src/main/java/nsusbloader/ModelControllers/Log.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
Copyright 2019-2020 Dmitry Isaenko
|
||||
|
||||
This file is part of NS-USBloader.
|
||||
|
||||
NS-USBloader is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
NS-USBloader is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with NS-USBloader. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package nsusbloader.ModelControllers;
|
||||
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLMain;
|
||||
|
||||
public class Log {
|
||||
|
||||
private Log(){}
|
||||
|
||||
public static ILogPrinter getPrinter(EModule whoIsAsking){
|
||||
if (NSLMain.isCli)
|
||||
return new LogPrinterCli();
|
||||
else
|
||||
return new LogPrinterGui(whoIsAsking);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package nsusbloader.ModelControllers;
|
||||
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class LogPrinterCli implements ILogPrinter{
|
||||
@Override
|
||||
public void print(String message, EMsgType type) {
|
||||
switch (type){
|
||||
case PASS:
|
||||
System.out.println("P: "+message);
|
||||
break;
|
||||
case FAIL:
|
||||
System.out.println("F: "+message);
|
||||
break;
|
||||
case INFO:
|
||||
System.out.println("I: "+message);
|
||||
break;
|
||||
case WARNING:
|
||||
System.out.println("W: "+message);
|
||||
break;
|
||||
default:
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(Double value) { }
|
||||
@Override
|
||||
public void update(HashMap<String, File> nspMap, EFileStatus status) { }
|
||||
@Override
|
||||
public void update(File file, EFileStatus status) { }
|
||||
@Override
|
||||
public void updateOneLinerStatus(boolean status){ }
|
||||
@Override
|
||||
public void close() {
|
||||
System.out.println("\n-\n");
|
||||
}
|
||||
}
|
|
@ -26,23 +26,27 @@ import java.io.File;
|
|||
import java.util.HashMap;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class LogPrinter {
|
||||
private MessagesConsumer msgConsumer;
|
||||
private BlockingQueue<String> msgQueue;
|
||||
private BlockingQueue<Double> progressQueue;
|
||||
private HashMap<String, EFileStatus> statusMap; // BlockingQueue for literally one object. TODO: read more books ; replace to hashMap
|
||||
public class LogPrinterGui implements ILogPrinter {
|
||||
private final MessagesConsumer msgConsumer;
|
||||
private final BlockingQueue<String> msgQueue;
|
||||
private final BlockingQueue<Double> progressQueue;
|
||||
private final HashMap<String, EFileStatus> statusMap; // BlockingQueue for literally one object. TODO: read more books ; replace to hashMap
|
||||
private AtomicBoolean oneLinerStatus;
|
||||
|
||||
public LogPrinter(EModule whoIsAsking){
|
||||
public LogPrinterGui(EModule whoIsAsking){
|
||||
this.msgQueue = new LinkedBlockingQueue<>();
|
||||
this.progressQueue = new LinkedBlockingQueue<>();
|
||||
this.statusMap = new HashMap<>();
|
||||
this.msgConsumer = new MessagesConsumer(whoIsAsking, this.msgQueue, this.progressQueue, this.statusMap);
|
||||
this.oneLinerStatus = new AtomicBoolean();
|
||||
this.msgConsumer = new MessagesConsumer(whoIsAsking, this.msgQueue, this.progressQueue, this.statusMap, this.oneLinerStatus);
|
||||
this.msgConsumer.start();
|
||||
}
|
||||
/**
|
||||
* This is what will print to textArea of the application.
|
||||
* */
|
||||
@Override
|
||||
public void print(String message, EMsgType type){
|
||||
try {
|
||||
switch (type){
|
||||
|
@ -69,6 +73,7 @@ public class LogPrinter {
|
|||
/**
|
||||
* Update progress for progress bar
|
||||
* */
|
||||
@Override
|
||||
public void updateProgress(Double value) {
|
||||
try {
|
||||
progressQueue.put(value);
|
||||
|
@ -78,6 +83,7 @@ public class LogPrinter {
|
|||
/**
|
||||
* When we're done - update status
|
||||
* */
|
||||
@Override
|
||||
public void update(HashMap<String, File> nspMap, EFileStatus status){
|
||||
for (File file: nspMap.values())
|
||||
statusMap.putIfAbsent(file.getName(), status);
|
||||
|
@ -85,12 +91,19 @@ public class LogPrinter {
|
|||
/**
|
||||
* When we're done - update status
|
||||
* */
|
||||
@Override
|
||||
public void update(File file, EFileStatus status){
|
||||
statusMap.putIfAbsent(file.getName(), status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOneLinerStatus(boolean status){
|
||||
oneLinerStatus.set(status);
|
||||
}
|
||||
/**
|
||||
* When we're done - close it
|
||||
* */
|
||||
@Override
|
||||
public void close(){
|
||||
msgConsumer.interrupt();
|
||||
}
|
|
@ -26,10 +26,12 @@ import nsusbloader.Controllers.NSTableViewController;
|
|||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.NSLDataTypes.EFileStatus;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class MessagesConsumer extends AnimationTimer {
|
||||
private final BlockingQueue<String> msgQueue;
|
||||
|
@ -41,9 +43,15 @@ public class MessagesConsumer extends AnimationTimer {
|
|||
private final NSTableViewController tableViewController;
|
||||
private final EModule appModuleType;
|
||||
|
||||
private AtomicBoolean oneLinerStatus;
|
||||
|
||||
private boolean isInterrupted;
|
||||
|
||||
MessagesConsumer(EModule appModuleType, BlockingQueue<String> msgQueue, BlockingQueue<Double> progressQueue, HashMap<String, EFileStatus> statusMap){
|
||||
MessagesConsumer(EModule appModuleType,
|
||||
BlockingQueue<String> msgQueue,
|
||||
BlockingQueue<Double> progressQueue,
|
||||
HashMap<String, EFileStatus> statusMap,
|
||||
AtomicBoolean oneLinerStatus) {
|
||||
this.appModuleType = appModuleType;
|
||||
this.isInterrupted = false;
|
||||
|
||||
|
@ -56,6 +64,8 @@ public class MessagesConsumer extends AnimationTimer {
|
|||
this.statusMap = statusMap;
|
||||
this.tableViewController = MediatorControl.getInstance().getContoller().FrontTabController.tableFilesListController;
|
||||
|
||||
this.oneLinerStatus = oneLinerStatus;
|
||||
|
||||
progressBar.setProgress(0.0);
|
||||
|
||||
progressBar.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);
|
||||
|
@ -84,9 +94,15 @@ public class MessagesConsumer extends AnimationTimer {
|
|||
MediatorControl.getInstance().setBgThreadActive(false, appModuleType);
|
||||
progressBar.setProgress(0.0);
|
||||
|
||||
if (statusMap.size() > 0)
|
||||
if (statusMap.size() > 0){
|
||||
for (String key : statusMap.keySet())
|
||||
tableViewController.setFileStatus(key, statusMap.get(key));
|
||||
}
|
||||
//TODO: rewrite
|
||||
if (appModuleType.equals(EModule.RCM)){
|
||||
MediatorControl.getInstance().getContoller().getRcmCtrlr().setOneLineStatus(oneLinerStatus.get());
|
||||
}
|
||||
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,17 @@ import javafx.scene.Scene;
|
|||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
import nsusbloader.Controllers.NSLMainController;
|
||||
import nsusbloader.Utilities.Rcm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
public class NSLMain extends Application {
|
||||
|
||||
public static final String appVersion = "v3.0";
|
||||
public static final String appVersion = "v4.0";
|
||||
public static boolean isCli;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception{
|
||||
|
@ -86,9 +89,11 @@ public class NSLMain extends Application {
|
|||
}
|
||||
|
||||
private static boolean handleCli(String[] args){
|
||||
if (args.length != 1)
|
||||
if (args.length == 0)
|
||||
return false;
|
||||
|
||||
NSLMain.isCli = true;
|
||||
|
||||
try {
|
||||
switch (args[0]) {
|
||||
case "-v":
|
||||
|
@ -104,19 +109,44 @@ public class NSLMain extends Application {
|
|||
else
|
||||
System.out.println("Nothing to remove");
|
||||
return true;
|
||||
case "--rcm": // TODO: rewrite
|
||||
if (args.length < 2){
|
||||
System.out.println("No payload file specified. Expected:\n"
|
||||
+ "... file.jar --rcm payload.bin\n" + "or\n"
|
||||
+ "... file.jar --rcm /home/user/payload.bin\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isWindows = false;
|
||||
if (System.getProperty("os.name").toLowerCase().replace(" ", "").contains("windows"))
|
||||
isWindows = true;
|
||||
|
||||
if (isWindows) {
|
||||
if (! args[1].matches("^.:\\\\.*$"))
|
||||
args[1] = System.getProperty("user.dir") + File.separator + args[1];
|
||||
}
|
||||
else {
|
||||
if (! args[1].startsWith("/"))
|
||||
args[1] = System.getProperty("user.dir") + File.separator + args[1];
|
||||
}
|
||||
|
||||
Rcm rcm = new Rcm(args[1]);
|
||||
Thread rcmThread = new Thread(rcm);
|
||||
rcmThread.start();
|
||||
return true;
|
||||
case "--help":
|
||||
default:
|
||||
System.out.println("CLI Usage:\n"
|
||||
+ "\t --rcm payload.bin\tSend payload\n"
|
||||
+ "\t-c, --clean\tRemove/reset settings and exit\n"
|
||||
+ "\t-v, --version \tShow application version\n"
|
||||
+ "\t-h, --help\t\tShow this message");
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,18 +20,19 @@ package nsusbloader.Utilities;
|
|||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.COM.USB.UsbConnect;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.ModelControllers.Log;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import org.usb4java.DeviceHandle;
|
||||
|
||||
public class NxdtTask extends Task<Boolean> {
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
private String saveToLocation;
|
||||
|
||||
public NxdtTask(String saveToLocation){
|
||||
this.logPrinter = new LogPrinter(EModule.NXDT);
|
||||
this.logPrinter = Log.getPrinter(EModule.NXDT);
|
||||
this.saveToLocation = saveToLocation;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package nsusbloader.Utilities;
|
|||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.COM.USB.UsbErrorCodes;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import org.usb4java.DeviceHandle;
|
||||
import org.usb4java.LibUsb;
|
||||
|
@ -33,7 +33,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.Arrays;
|
||||
|
||||
class NxdtUsbAbi1 {
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
private DeviceHandle handlerNS;
|
||||
private Task<Boolean> task;
|
||||
private String saveToPath;
|
||||
|
@ -80,7 +80,7 @@ class NxdtUsbAbi1 {
|
|||
|
||||
public NxdtUsbAbi1(DeviceHandle handler,
|
||||
Task<Boolean> task,
|
||||
LogPrinter logPrinter,
|
||||
ILogPrinter logPrinter,
|
||||
String saveToPath
|
||||
){
|
||||
this.handlerNS = handler;
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
*/
|
||||
package nsusbloader.Utilities;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.COM.USB.UsbConnect;
|
||||
import nsusbloader.COM.USB.UsbErrorCodes;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.ModelControllers.Log;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
import org.usb4java.*;
|
||||
|
@ -37,13 +37,15 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RcmTask extends Task<Boolean> {
|
||||
public class Rcm implements Runnable{
|
||||
|
||||
private boolean status = false;
|
||||
|
||||
private enum ECurrentOS {
|
||||
win, lin, mac, unsupported
|
||||
}
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
private String filePath;
|
||||
|
||||
private DeviceHandle handler;
|
||||
|
@ -65,13 +67,13 @@ public class RcmTask extends Task<Boolean> {
|
|||
|
||||
private static final byte[] sprayPttrn = { 0x00, 0x00, 0x01, 0x40};
|
||||
|
||||
public RcmTask(String filePath){
|
||||
this.logPrinter = new LogPrinter(EModule.RCM);
|
||||
public Rcm(String filePath){
|
||||
this.logPrinter = Log.getPrinter(EModule.RCM);
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean call() {
|
||||
public void run() {
|
||||
logPrinter.print("Selected: "+filePath, EMsgType.INFO);
|
||||
logPrinter.print("=============== RCM ===============", EMsgType.INFO);
|
||||
|
||||
|
@ -94,13 +96,13 @@ public class RcmTask extends Task<Boolean> {
|
|||
"\n But you could file a bug with request."+
|
||||
"\n\n Nothing has been sent to NS. Execution stopped.", EMsgType.FAIL);
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (preparePayload()){
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
// === TEST THIS ===
|
||||
// writeTestFile();
|
||||
|
@ -111,7 +113,7 @@ public class RcmTask extends Task<Boolean> {
|
|||
|
||||
if (! usbConnect.isConnected()){
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
this.handler = usbConnect.getNsHandler();
|
||||
|
||||
|
@ -119,7 +121,7 @@ public class RcmTask extends Task<Boolean> {
|
|||
if (readUsbDeviceID()){
|
||||
usbConnect.close();
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
// Send payload
|
||||
for (int i=0; i < fullPayload.length / 4096 ; i++){
|
||||
|
@ -128,7 +130,7 @@ public class RcmTask extends Task<Boolean> {
|
|||
"\n\n Execution stopped.", EMsgType.FAIL);
|
||||
usbConnect.close();
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
logPrinter.print("Information sent to NS.", EMsgType.PASS);
|
||||
|
@ -137,7 +139,7 @@ public class RcmTask extends Task<Boolean> {
|
|||
if (smashMacOS()){
|
||||
usbConnect.close();
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -153,7 +155,7 @@ public class RcmTask extends Task<Boolean> {
|
|||
"\n\n Execution stopped and failed. And it's strange.", EMsgType.FAIL);
|
||||
usbConnect.close();
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (retval != 0){
|
||||
|
@ -161,14 +163,13 @@ public class RcmTask extends Task<Boolean> {
|
|||
"\n\n Execution stopped and failed.", EMsgType.FAIL);
|
||||
usbConnect.close();
|
||||
logPrinter.close();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
logPrinter.print(".:: Payload complete ::.", EMsgType.PASS);
|
||||
|
||||
usbConnect.close();
|
||||
logPrinter.updateOneLinerStatus(true);
|
||||
logPrinter.close();
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Prepare the 'big' or full-size byte-buffer that is actually is a payload that we're about to use.
|
|
@ -19,7 +19,8 @@
|
|||
package nsusbloader.Utilities;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import nsusbloader.ModelControllers.LogPrinter;
|
||||
import nsusbloader.ModelControllers.ILogPrinter;
|
||||
import nsusbloader.ModelControllers.Log;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
import nsusbloader.NSLDataTypes.EMsgType;
|
||||
|
||||
|
@ -39,14 +40,14 @@ public class SplitMergeTool {
|
|||
|
||||
class SplitTask extends Task<Boolean>{
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
private String saveToPath;
|
||||
private String filePath;
|
||||
|
||||
SplitTask(String filePath, String saveToPath){
|
||||
this.filePath = filePath;
|
||||
this.saveToPath = saveToPath;
|
||||
logPrinter = new LogPrinter(EModule.SPLIT_MERGE_TOOL);
|
||||
logPrinter = Log.getPrinter(EModule.SPLIT_MERGE_TOOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,14 +183,14 @@ class SplitTask extends Task<Boolean>{
|
|||
|
||||
class MergeTask extends Task<Boolean> {
|
||||
|
||||
private LogPrinter logPrinter;
|
||||
private ILogPrinter logPrinter;
|
||||
private String saveToPath;
|
||||
private String filePath;
|
||||
|
||||
MergeTask(String filePath, String saveToPath) {
|
||||
this.filePath = filePath;
|
||||
this.saveToPath = saveToPath;
|
||||
logPrinter = new LogPrinter(EModule.SPLIT_MERGE_TOOL);
|
||||
logPrinter = Log.getPrinter(EModule.SPLIT_MERGE_TOOL);
|
||||
}
|
||||
@Override
|
||||
protected Boolean call() {
|
||||
|
|
Loading…
Reference in a new issue