Compare commits

...

2 commits

24 changed files with 331 additions and 155 deletions

View file

@ -8,7 +8,7 @@
<name>NS-USBloader</name> <name>NS-USBloader</name>
<artifactId>ns-usbloader</artifactId> <artifactId>ns-usbloader</artifactId>
<version>3.0-SNAPSHOT</version> <version>4.0-SNAPSHOT</version>
<url>https://github.com/developersu/ns-usbloader/</url> <url>https://github.com/developersu/ns-usbloader/</url>
<description> <description>

View file

@ -19,8 +19,9 @@
package nsusbloader.COM.NET; package nsusbloader.COM.NET;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.Log;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import nsusbloader.COM.Helpers.NSSplitReader; import nsusbloader.COM.Helpers.NSSplitReader;
@ -33,7 +34,7 @@ import java.util.*;
public class NETCommunications extends Task<Void> { // todo: thows IOException? public class NETCommunications extends Task<Void> { // todo: thows IOException?
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private String hostIP; private String hostIP;
private int hostPort; private int hostPort;
@ -61,7 +62,7 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
else else
this.extras = ""; this.extras = "";
this.switchIP = switchIP; this.switchIP = switchIP;
this.logPrinter = new LogPrinter(EModule.USB_NET_TRANSFERS); this.logPrinter = Log.getPrinter(EModule.USB_NET_TRANSFERS);
this.nspMap = new HashMap<>(); this.nspMap = new HashMap<>();
this.nspFileSizes = new HashMap<>(); this.nspFileSizes = new HashMap<>();
// Filter and remove empty/incorrect split-files // Filter and remove empty/incorrect split-files

View file

@ -22,7 +22,7 @@ import javafx.application.Platform;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import nsusbloader.COM.Helpers.NSSplitReader; import nsusbloader.COM.Helpers.NSSplitReader;
import org.usb4java.DeviceHandle; import org.usb4java.DeviceHandle;
@ -69,7 +69,7 @@ class GoldLeaf extends TransferModule {
// For using in CMD_SelectFile with SPEC:/ prefix // For using in CMD_SelectFile with SPEC:/ prefix
private File selectedFile; 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); super(handler, nspMap, task, logPrinter);
final byte CMD_GetDriveCount = 1; final byte CMD_GetDriveCount = 1;

View file

@ -19,7 +19,7 @@
package nsusbloader.COM.USB; package nsusbloader.COM.USB;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import nsusbloader.COM.Helpers.NSSplitReader; import nsusbloader.COM.Helpers.NSSplitReader;
@ -53,7 +53,7 @@ public class GoldLeaf_05 extends TransferModule {
private RandomAccessFile raf; // NSP File private RandomAccessFile raf; // NSP File
private NSSplitReader nsr; // It'a also 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); super(handler, nspMap, task, logPrinter);
status = EFileStatus.FAILED; status = EFileStatus.FAILED;

View file

@ -23,7 +23,7 @@ import javafx.concurrent.Task;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import nsusbloader.COM.Helpers.NSSplitReader; import nsusbloader.COM.Helpers.NSSplitReader;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import org.usb4java.DeviceHandle; import org.usb4java.DeviceHandle;
import org.usb4java.LibUsb; import org.usb4java.LibUsb;
@ -69,7 +69,7 @@ class GoldLeaf_07 extends TransferModule {
// For using in CMD_SelectFile with SPEC:/ prefix // For using in CMD_SelectFile with SPEC:/ prefix
private File selectedFile; 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); super(handler, nspMap, task, logPrinter);
final byte CMD_GetDriveCount = 0x00; final byte CMD_GetDriveCount = 0x00;

View file

@ -18,7 +18,7 @@
*/ */
package nsusbloader.COM.USB.PFS; package nsusbloader.COM.USB.PFS;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import java.io.*; import java.io.*;
@ -38,7 +38,7 @@ public class PFSProvider {
private long bodySize; private long bodySize;
private int ticketID = -1; private int ticketID = -1;
public PFSProvider(File nspFile, LogPrinter logPrinter) throws Exception{ public PFSProvider(File nspFile, ILogPrinter logPrinter) throws Exception{
if (nspFile.isDirectory()) { if (nspFile.isDirectory()) {
nspFileName = nspFile.getName(); nspFileName = nspFile.getName();
nspFile = new File(nspFile.getAbsolutePath() + File.separator + "00"); nspFile = new File(nspFile.getAbsolutePath() + File.separator + "00");

View file

@ -19,7 +19,7 @@
package nsusbloader.COM.USB; package nsusbloader.COM.USB;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import nsusbloader.COM.Helpers.NSSplitReader; import nsusbloader.COM.Helpers.NSSplitReader;
@ -48,7 +48,7 @@ class TinFoil extends TransferModule {
/* byte[] magic = new byte[4]; /* byte[] magic = new byte[4];
ByteBuffer bb = StandardCharsets.UTF_8.encode("TUC0").rewind().get(magic); // Let's rephrase this 'string' */ 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); super(handler, nspMap, task, logPrinter);
logPrinter.print("============= Tinfoil =============", EMsgType.INFO); logPrinter.print("============= Tinfoil =============", EMsgType.INFO);

View file

@ -19,7 +19,7 @@
package nsusbloader.COM.USB; package nsusbloader.COM.USB;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import org.usb4java.DeviceHandle; import org.usb4java.DeviceHandle;
@ -31,11 +31,11 @@ public abstract class TransferModule {
EFileStatus status = EFileStatus.UNKNOWN; EFileStatus status = EFileStatus.UNKNOWN;
LinkedHashMap<String, File> nspMap; LinkedHashMap<String, File> nspMap;
LogPrinter logPrinter; ILogPrinter logPrinter;
DeviceHandle handlerNS; DeviceHandle handlerNS;
Task<Void> task; 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.handlerNS = handler;
this.nspMap = nspMap; this.nspMap = nspMap;
this.task = task; this.task = task;

View file

@ -19,7 +19,8 @@
package nsusbloader.COM.USB; package nsusbloader.COM.USB;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.ModelControllers.Log;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
@ -32,7 +33,7 @@ import java.util.*;
// TODO: add filter option to show only NSP files // TODO: add filter option to show only NSP files
public class UsbCommunications extends Task<Void> { public class UsbCommunications extends Task<Void> {
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private LinkedHashMap<String, File> nspMap; private LinkedHashMap<String, File> nspMap;
private String protocol; private String protocol;
private boolean nspFilterForGl; private boolean nspFilterForGl;
@ -43,7 +44,7 @@ public class UsbCommunications extends Task<Void> {
this.nspMap = new LinkedHashMap<>(); this.nspMap = new LinkedHashMap<>();
for (File f: nspList) for (File f: nspList)
nspMap.put(f.getName(), f); nspMap.put(f.getName(), f);
this.logPrinter = new LogPrinter(EModule.USB_NET_TRANSFERS); this.logPrinter = Log.getPrinter(EModule.USB_NET_TRANSFERS);
} }
@Override @Override

View file

@ -18,7 +18,7 @@
*/ */
package nsusbloader.COM.USB; package nsusbloader.COM.USB;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import org.usb4java.*; import org.usb4java.*;
@ -39,7 +39,7 @@ public class UsbConnect {
private DeviceHandle handlerNS; private DeviceHandle handlerNS;
private Device deviceNS; private Device deviceNS;
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private boolean connected; // TODO: replace to 'connectionFailure' and invert requests everywhere private boolean connected; // TODO: replace to 'connectionFailure' and invert requests everywhere
@ -49,7 +49,7 @@ public class UsbConnect {
private int returningValue; private int returningValue;
private DeviceList deviceList; private DeviceList deviceList;
public static UsbConnect connectRcmMode(LogPrinter logPrinter){ public static UsbConnect connectRcmMode(ILogPrinter logPrinter){
UsbConnect usbConnect = new UsbConnect(logPrinter); UsbConnect usbConnect = new UsbConnect(logPrinter);
usbConnect.VENDOR_ID = RCM_VID; usbConnect.VENDOR_ID = RCM_VID;
usbConnect.PRODUCT_ID = RCM_PID; usbConnect.PRODUCT_ID = RCM_PID;
@ -71,7 +71,7 @@ public class UsbConnect {
return usbConnect; return usbConnect;
} }
public static UsbConnect connectHomebrewMode(LogPrinter logPrinter){ public static UsbConnect connectHomebrewMode(ILogPrinter logPrinter){
UsbConnect usbConnect = new UsbConnect(logPrinter); UsbConnect usbConnect = new UsbConnect(logPrinter);
usbConnect.VENDOR_ID = HOMEBREW_VID; usbConnect.VENDOR_ID = HOMEBREW_VID;
usbConnect.PRODUCT_ID = HOMEBREW_PID; usbConnect.PRODUCT_ID = HOMEBREW_PID;
@ -96,7 +96,7 @@ public class UsbConnect {
private UsbConnect(){} private UsbConnect(){}
private UsbConnect(LogPrinter logPrinter){ private UsbConnect(ILogPrinter logPrinter){
this.logPrinter = logPrinter; this.logPrinter = logPrinter;
this.connected = false; this.connected = false;
}; };

View file

@ -89,10 +89,7 @@ public class FrontController implements Initializable {
} }
} }
// Really bad disable-enable upload button function // Really bad disable-enable upload button function
if (tableFilesListController.isFilesForUploadListEmpty()) disableUploadStopBtn(tableFilesListController.isFilesForUploadListEmpty());
disableUploadStopBtn(true);
else
disableUploadStopBtn(false);
}); // Add listener to notify tableView controller }); // Add listener to notify tableView controller
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // 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()); this.switchThemeBtn.setOnAction(e->switchTheme());
if (getSelectedProtocol().equals("TinFoil")) uploadStopBtn.setDisable(getSelectedProtocol().equals("TinFoil"));
uploadStopBtn.setDisable(true);
else
uploadStopBtn.setDisable(false);
selectNspBtn.setOnAction(e-> selectFilesBtnAction()); selectNspBtn.setOnAction(e-> selectFilesBtnAction());
selectSplitNspBtn.setOnAction(e-> selectSplitBtnAction()); selectSplitNspBtn.setOnAction(e-> selectSplitBtnAction());
@ -157,15 +151,19 @@ public class FrontController implements Initializable {
* Changes UI theme on the go * Changes UI theme on the go
* */ * */
private void switchTheme(){ private void switchTheme(){
if (switchThemeBtn.getScene().getStylesheets().get(0).equals("/res/app_dark.css")) { final String darkTheme = "/res/app_dark.css";
switchThemeBtn.getScene().getStylesheets().remove("/res/app_dark.css"); final String lightTheme = "/res/app_light.css";
switchThemeBtn.getScene().getStylesheets().add("/res/app_light.css"); final ObservableList<String> styleSheets = switchThemeBtn.getScene().getStylesheets();
if (styleSheets.get(0).equals(darkTheme)) {
styleSheets.remove(darkTheme);
styleSheets.add(lightTheme);
} }
else { else {
switchThemeBtn.getScene().getStylesheets().remove("/res/app_light.css"); styleSheets.remove(lightTheme);
switchThemeBtn.getScene().getStylesheets().add("/res/app_dark.css"); styleSheets.add(darkTheme);
} }
AppPreferences.getInstance().setTheme(switchThemeBtn.getScene().getStylesheets().get(0)); AppPreferences.getInstance().setTheme(styleSheets.get(0));
} }
/** /**
* Get selected protocol (GL/TF) * Get selected protocol (GL/TF)
@ -186,8 +184,6 @@ public class FrontController implements Initializable {
return nsIpTextField.getText(); return nsIpTextField.getText();
} }
/*-****************************************************************************************************************-*/
/** /**
* Functionality for selecting NSP button. * Functionality for selecting NSP button.
* */ * */
@ -244,59 +240,60 @@ public class FrontController implements Initializable {
* It's button listener when no transmission executes * It's button listener when no transmission executes
* */ * */
private void uploadBtnAction(){ private void uploadBtnAction(){
if ((workThread == null || !workThread.isAlive())){ if (workThread != null && workThread.isAlive())
return;
// Collect files // Collect files
List<File> nspToUpload; 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; return;
} }
else {
if ((nspToUpload = tableFilesListController.getFilesForUpload()) != null){ if ((nspToUpload = tableFilesListController.getFilesForUpload()) != null){
MediatorControl.getInstance().getContoller().logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\n"); logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\n");
for (File item: nspToUpload) nspToUpload.forEach(item -> logArea.appendText(" "+item.getAbsolutePath()+"\n"));
MediatorControl.getInstance().getContoller().logArea.appendText(" "+item.getAbsolutePath()+"\n");
} }
else { else {
MediatorControl.getInstance().getContoller().logArea.clear(); logArea.clear();
nspToUpload = new LinkedList<>(); nspToUpload = new LinkedList<>();
} }
}
SettingsController settings = MediatorControl.getInstance().getContoller().getSettingsCtrlr();
// If USB selected // If USB selected
if (getSelectedProtocol().equals("GoldLeaf") || if (getSelectedProtocol().equals("GoldLeaf") || ( getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("USB") ) ){
( getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("USB") ) usbNetCommunications = new UsbCommunications(nspToUpload, getSelectedProtocol() + settings.getGlOldVer(), settings.getNSPFileFilterForGL());
){
usbNetCommunications = new UsbCommunications(nspToUpload, getSelectedProtocol()+MediatorControl.getInstance().getContoller().getSettingsCtrlr().getGlOldVer(), MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL());
workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true);
workThread.start();
} }
else { // NET INSTALL OVER TINFOIL 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])$")) 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 (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"),resourceBundle.getString("windowBodyBadIp")))
if (settings.isNsIpValidate() && ! getNsIp().matches(ipValidationPattern)) {
if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"), resourceBundle.getString("windowBodyBadIp")))
return; return;
}
String nsIP = getNsIp(); String nsIP = getNsIp();
if (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getExpertModeSelected()) if (! settings.getExpertModeSelected())
usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", ""); usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", "");
else { else {
usbNetCommunications = new NETCommunications( usbNetCommunications = new NETCommunications(
nspToUpload, nspToUpload,
nsIP, nsIP,
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNotServeSelected(), settings.getNotServeSelected(),
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getAutoIpSelected()?"":MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostIp(), settings.getAutoIpSelected()?"":settings.getHostIp(),
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getRandPortSelected()?"":MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostPort(), settings.getRandPortSelected()?"":settings.getHostPort(),
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNotServeSelected()?MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostExtra():"" settings.getNotServeSelected()?settings.getHostExtra():""
); );
} }
}
workThread = new Thread(usbNetCommunications); workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true); workThread.setDaemon(true);
workThread.start(); workThread.start();
} }
}
}
/** /**
* It's button listener when transmission in progress * It's button listener when transmission in progress
* */ * */
@ -320,10 +317,11 @@ public class FrontController implements Initializable {
@FXML @FXML
private void handleDrop(DragEvent event){ private void handleDrop(DragEvent event){
List<File> filesDropped = event.getDragboard().getFiles(); 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$)")); 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$"))); filesDropped.removeIf(file -> (file.isDirectory() && ! file.getName().toLowerCase().matches(".*\\.nsp$")));
else else
filesDropped.removeIf(file -> ! file.getName().toLowerCase().matches(".*\\.nsp$")); filesDropped.removeIf(file -> ! file.getName().toLowerCase().matches(".*\\.nsp$"));
@ -339,7 +337,7 @@ public class FrontController implements Initializable {
* Called from mediator * Called from mediator
* TODO: remove shitcoding practices * 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)){ if (! type.equals(EModule.USB_NET_TRANSFERS)){
usbNetPane.setDisable(isActive); usbNetPane.setDisable(isActive);
return; return;

View file

@ -18,7 +18,6 @@
*/ */
package nsusbloader.Controllers; package nsusbloader.Controllers;
import javafx.concurrent.Task;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
@ -36,7 +35,7 @@ import nsusbloader.AppPreferences;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.ServiceWindow; import nsusbloader.ServiceWindow;
import nsusbloader.Utilities.RcmTask; import nsusbloader.Utilities.Rcm;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
@ -199,37 +198,32 @@ public class RcmController implements Initializable {
return; return;
} }
Task<Boolean> RcmTask; Rcm rcmTask;
RadioButton selectedRadio = (RadioButton)rcmToggleGrp.getSelectedToggle(); RadioButton selectedRadio = (RadioButton)rcmToggleGrp.getSelectedToggle();
switch (selectedRadio.getId()){ switch (selectedRadio.getId()){
case "pldrRadio1": case "pldrRadio1":
RcmTask = new RcmTask(payloadFPathLbl1.getText()); rcmTask = new Rcm(payloadFPathLbl1.getText());
break; break;
case "pldrRadio2": case "pldrRadio2":
RcmTask = new RcmTask(payloadFPathLbl2.getText()); rcmTask = new Rcm(payloadFPathLbl2.getText());
break; break;
case "pldrRadio3": case "pldrRadio3":
RcmTask = new RcmTask(payloadFPathLbl3.getText()); rcmTask = new Rcm(payloadFPathLbl3.getText());
break; break;
case "pldrRadio4": case "pldrRadio4":
RcmTask = new RcmTask(payloadFPathLbl4.getText()); rcmTask = new Rcm(payloadFPathLbl4.getText());
break; break;
case "pldrRadio5": case "pldrRadio5":
RcmTask = new RcmTask(payloadFPathLbl5.getText()); rcmTask = new Rcm(payloadFPathLbl5.getText());
break; break;
default: default:
return; return;
} }
RcmTask.setOnSucceeded(event -> { Thread rcmThread = new Thread(rcmTask);
if (RcmTask.getValue())
statusLbl.setText(rb.getString("done_txt")); rcmThread.setDaemon(true);
else rcmThread.start();
statusLbl.setText(rb.getString("failure_txt"));
});
Thread RcmThread = new Thread(RcmTask);
RcmThread.setDaemon(true);
RcmThread.start();
} }
@FXML @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); rcmToolPane.setDisable(isStart);
if (type.equals(EModule.RCM) && isStart){ if (type.equals(EModule.RCM) && isStart){
MediatorControl.getInstance().getContoller().logArea.clear(); MediatorControl.getInstance().getContoller().logArea.clear();

View file

@ -41,9 +41,9 @@ public class MediatorControl {
public synchronized void setBgThreadActive(boolean isActive, EModule appModuleType) { public synchronized void setBgThreadActive(boolean isActive, EModule appModuleType) {
isTransferActive.set(isActive); isTransferActive.set(isActive);
mainCtrler.getFrontCtrlr().notifyTransmThreadStarted(isActive, appModuleType); mainCtrler.getFrontCtrlr().notifyThreadStarted(isActive, appModuleType);
mainCtrler.getSmCtrlr().notifySmThreadStarted(isActive, appModuleType); mainCtrler.getSmCtrlr().notifySmThreadStarted(isActive, appModuleType);
mainCtrler.getRcmCtrlr().notifySmThreadStarted(isActive, appModuleType); mainCtrler.getRcmCtrlr().notifyThreadStarted(isActive, appModuleType);
mainCtrler.getNXDTabController().notifyThreadStarted(isActive, appModuleType); mainCtrler.getNXDTabController().notifyThreadStarted(isActive, appModuleType);
} }
public synchronized boolean getTransferActive() { return this.isTransferActive.get(); } public synchronized boolean getTransferActive() { return this.isTransferActive.get(); }

View 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();
}

View 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);
}
}

View file

@ -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");
}
}

View file

@ -26,23 +26,27 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
public class LogPrinter { public class LogPrinterGui implements ILogPrinter {
private MessagesConsumer msgConsumer; private final MessagesConsumer msgConsumer;
private BlockingQueue<String> msgQueue; private final BlockingQueue<String> msgQueue;
private BlockingQueue<Double> progressQueue; private final BlockingQueue<Double> progressQueue;
private HashMap<String, EFileStatus> statusMap; // BlockingQueue for literally one object. TODO: read more books ; replace to hashMap 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.msgQueue = new LinkedBlockingQueue<>();
this.progressQueue = new LinkedBlockingQueue<>(); this.progressQueue = new LinkedBlockingQueue<>();
this.statusMap = new HashMap<>(); 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.msgConsumer.start();
} }
/** /**
* This is what will print to textArea of the application. * This is what will print to textArea of the application.
* */ * */
@Override
public void print(String message, EMsgType type){ public void print(String message, EMsgType type){
try { try {
switch (type){ switch (type){
@ -69,6 +73,7 @@ public class LogPrinter {
/** /**
* Update progress for progress bar * Update progress for progress bar
* */ * */
@Override
public void updateProgress(Double value) { public void updateProgress(Double value) {
try { try {
progressQueue.put(value); progressQueue.put(value);
@ -78,6 +83,7 @@ public class LogPrinter {
/** /**
* When we're done - update status * When we're done - update status
* */ * */
@Override
public void update(HashMap<String, File> nspMap, EFileStatus status){ public void update(HashMap<String, File> nspMap, EFileStatus status){
for (File file: nspMap.values()) for (File file: nspMap.values())
statusMap.putIfAbsent(file.getName(), status); statusMap.putIfAbsent(file.getName(), status);
@ -85,12 +91,19 @@ public class LogPrinter {
/** /**
* When we're done - update status * When we're done - update status
* */ * */
@Override
public void update(File file, EFileStatus status){ public void update(File file, EFileStatus status){
statusMap.putIfAbsent(file.getName(), status); statusMap.putIfAbsent(file.getName(), status);
} }
@Override
public void updateOneLinerStatus(boolean status){
oneLinerStatus.set(status);
}
/** /**
* When we're done - close it * When we're done - close it
* */ * */
@Override
public void close(){ public void close(){
msgConsumer.interrupt(); msgConsumer.interrupt();
} }

View file

@ -26,10 +26,12 @@ import nsusbloader.Controllers.NSTableViewController;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
public class MessagesConsumer extends AnimationTimer { public class MessagesConsumer extends AnimationTimer {
private final BlockingQueue<String> msgQueue; private final BlockingQueue<String> msgQueue;
@ -41,9 +43,15 @@ public class MessagesConsumer extends AnimationTimer {
private final NSTableViewController tableViewController; private final NSTableViewController tableViewController;
private final EModule appModuleType; private final EModule appModuleType;
private AtomicBoolean oneLinerStatus;
private boolean isInterrupted; 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.appModuleType = appModuleType;
this.isInterrupted = false; this.isInterrupted = false;
@ -56,6 +64,8 @@ public class MessagesConsumer extends AnimationTimer {
this.statusMap = statusMap; this.statusMap = statusMap;
this.tableViewController = MediatorControl.getInstance().getContoller().FrontTabController.tableFilesListController; this.tableViewController = MediatorControl.getInstance().getContoller().FrontTabController.tableFilesListController;
this.oneLinerStatus = oneLinerStatus;
progressBar.setProgress(0.0); progressBar.setProgress(0.0);
progressBar.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS); progressBar.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);
@ -84,9 +94,15 @@ public class MessagesConsumer extends AnimationTimer {
MediatorControl.getInstance().setBgThreadActive(false, appModuleType); MediatorControl.getInstance().setBgThreadActive(false, appModuleType);
progressBar.setProgress(0.0); progressBar.setProgress(0.0);
if (statusMap.size() > 0) if (statusMap.size() > 0){
for (String key : statusMap.keySet()) for (String key : statusMap.keySet())
tableViewController.setFileStatus(key, statusMap.get(key)); tableViewController.setFileStatus(key, statusMap.get(key));
}
//TODO: rewrite
if (appModuleType.equals(EModule.RCM)){
MediatorControl.getInstance().getContoller().getRcmCtrlr().setOneLineStatus(oneLinerStatus.get());
}
this.stop(); this.stop();
} }
} }

View file

@ -25,14 +25,17 @@ import javafx.scene.Scene;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.stage.Stage; import javafx.stage.Stage;
import nsusbloader.Controllers.NSLMainController; import nsusbloader.Controllers.NSLMainController;
import nsusbloader.Utilities.Rcm;
import java.io.File;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
public class NSLMain extends Application { public class NSLMain extends Application {
public static final String appVersion = "v3.0"; public static final String appVersion = "v4.0";
public static boolean isCli;
@Override @Override
public void start(Stage primaryStage) throws Exception{ public void start(Stage primaryStage) throws Exception{
@ -86,9 +89,11 @@ public class NSLMain extends Application {
} }
private static boolean handleCli(String[] args){ private static boolean handleCli(String[] args){
if (args.length != 1) if (args.length == 0)
return false; return false;
NSLMain.isCli = true;
try { try {
switch (args[0]) { switch (args[0]) {
case "-v": case "-v":
@ -104,19 +109,44 @@ public class NSLMain extends Application {
else else
System.out.println("Nothing to remove"); System.out.println("Nothing to remove");
return true; 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": case "--help":
default:
System.out.println("CLI Usage:\n" System.out.println("CLI Usage:\n"
+ "\t --rcm payload.bin\tSend payload\n"
+ "\t-c, --clean\tRemove/reset settings and exit\n" + "\t-c, --clean\tRemove/reset settings and exit\n"
+ "\t-v, --version \tShow application version\n" + "\t-v, --version \tShow application version\n"
+ "\t-h, --help\t\tShow this message"); + "\t-h, --help\t\tShow this message");
return true; return true;
default:
return false;
} }
} }
catch (Exception e){ catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return false; return true;
} }
} }
} }

View file

@ -20,18 +20,19 @@ package nsusbloader.Utilities;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.COM.USB.UsbConnect; import nsusbloader.COM.USB.UsbConnect;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.ModelControllers.Log;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import org.usb4java.DeviceHandle; import org.usb4java.DeviceHandle;
public class NxdtTask extends Task<Boolean> { public class NxdtTask extends Task<Boolean> {
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private String saveToLocation; private String saveToLocation;
public NxdtTask(String saveToLocation){ public NxdtTask(String saveToLocation){
this.logPrinter = new LogPrinter(EModule.NXDT); this.logPrinter = Log.getPrinter(EModule.NXDT);
this.saveToLocation = saveToLocation; this.saveToLocation = saveToLocation;
} }

View file

@ -20,7 +20,7 @@ package nsusbloader.Utilities;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.COM.USB.UsbErrorCodes; import nsusbloader.COM.USB.UsbErrorCodes;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import org.usb4java.DeviceHandle; import org.usb4java.DeviceHandle;
import org.usb4java.LibUsb; import org.usb4java.LibUsb;
@ -33,7 +33,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
class NxdtUsbAbi1 { class NxdtUsbAbi1 {
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private DeviceHandle handlerNS; private DeviceHandle handlerNS;
private Task<Boolean> task; private Task<Boolean> task;
private String saveToPath; private String saveToPath;
@ -80,7 +80,7 @@ class NxdtUsbAbi1 {
public NxdtUsbAbi1(DeviceHandle handler, public NxdtUsbAbi1(DeviceHandle handler,
Task<Boolean> task, Task<Boolean> task,
LogPrinter logPrinter, ILogPrinter logPrinter,
String saveToPath String saveToPath
){ ){
this.handlerNS = handler; this.handlerNS = handler;

View file

@ -24,10 +24,10 @@
*/ */
package nsusbloader.Utilities; package nsusbloader.Utilities;
import javafx.concurrent.Task;
import nsusbloader.COM.USB.UsbConnect; import nsusbloader.COM.USB.UsbConnect;
import nsusbloader.COM.USB.UsbErrorCodes; import nsusbloader.COM.USB.UsbErrorCodes;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.ModelControllers.Log;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import org.usb4java.*; import org.usb4java.*;
@ -37,13 +37,15 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.Arrays; import java.util.Arrays;
public class RcmTask extends Task<Boolean> { public class Rcm implements Runnable{
private boolean status = false;
private enum ECurrentOS { private enum ECurrentOS {
win, lin, mac, unsupported win, lin, mac, unsupported
} }
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private String filePath; private String filePath;
private DeviceHandle handler; private DeviceHandle handler;
@ -65,13 +67,13 @@ public class RcmTask extends Task<Boolean> {
private static final byte[] sprayPttrn = { 0x00, 0x00, 0x01, 0x40}; private static final byte[] sprayPttrn = { 0x00, 0x00, 0x01, 0x40};
public RcmTask(String filePath){ public Rcm(String filePath){
this.logPrinter = new LogPrinter(EModule.RCM); this.logPrinter = Log.getPrinter(EModule.RCM);
this.filePath = filePath; this.filePath = filePath;
} }
@Override @Override
protected Boolean call() { public void run() {
logPrinter.print("Selected: "+filePath, EMsgType.INFO); logPrinter.print("Selected: "+filePath, EMsgType.INFO);
logPrinter.print("=============== RCM ===============", 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 But you could file a bug with request."+
"\n\n Nothing has been sent to NS. Execution stopped.", EMsgType.FAIL); "\n\n Nothing has been sent to NS. Execution stopped.", EMsgType.FAIL);
logPrinter.close(); logPrinter.close();
return false; return;
} }
} }
if (preparePayload()){ if (preparePayload()){
logPrinter.close(); logPrinter.close();
return false; return;
} }
// === TEST THIS === // === TEST THIS ===
// writeTestFile(); // writeTestFile();
@ -111,7 +113,7 @@ public class RcmTask extends Task<Boolean> {
if (! usbConnect.isConnected()){ if (! usbConnect.isConnected()){
logPrinter.close(); logPrinter.close();
return false; return;
} }
this.handler = usbConnect.getNsHandler(); this.handler = usbConnect.getNsHandler();
@ -119,7 +121,7 @@ public class RcmTask extends Task<Boolean> {
if (readUsbDeviceID()){ if (readUsbDeviceID()){
usbConnect.close(); usbConnect.close();
logPrinter.close(); logPrinter.close();
return false; return;
} }
// Send payload // Send payload
for (int i=0; i < fullPayload.length / 4096 ; i++){ 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); "\n\n Execution stopped.", EMsgType.FAIL);
usbConnect.close(); usbConnect.close();
logPrinter.close(); logPrinter.close();
return false; return;
} }
} }
logPrinter.print("Information sent to NS.", EMsgType.PASS); logPrinter.print("Information sent to NS.", EMsgType.PASS);
@ -137,7 +139,7 @@ public class RcmTask extends Task<Boolean> {
if (smashMacOS()){ if (smashMacOS()){
usbConnect.close(); usbConnect.close();
logPrinter.close(); logPrinter.close();
return false; return;
} }
} }
else { else {
@ -153,7 +155,7 @@ public class RcmTask extends Task<Boolean> {
"\n\n Execution stopped and failed. And it's strange.", EMsgType.FAIL); "\n\n Execution stopped and failed. And it's strange.", EMsgType.FAIL);
usbConnect.close(); usbConnect.close();
logPrinter.close(); logPrinter.close();
return false; return;
} }
if (retval != 0){ if (retval != 0){
@ -161,14 +163,13 @@ public class RcmTask extends Task<Boolean> {
"\n\n Execution stopped and failed.", EMsgType.FAIL); "\n\n Execution stopped and failed.", EMsgType.FAIL);
usbConnect.close(); usbConnect.close();
logPrinter.close(); logPrinter.close();
return false; return;
} }
} }
logPrinter.print(".:: Payload complete ::.", EMsgType.PASS); logPrinter.print(".:: Payload complete ::.", EMsgType.PASS);
usbConnect.close(); usbConnect.close();
logPrinter.updateOneLinerStatus(true);
logPrinter.close(); logPrinter.close();
return true;
} }
/** /**
* Prepare the 'big' or full-size byte-buffer that is actually is a payload that we're about to use. * Prepare the 'big' or full-size byte-buffer that is actually is a payload that we're about to use.

View file

@ -19,7 +19,8 @@
package nsusbloader.Utilities; package nsusbloader.Utilities;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.ModelControllers.Log;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
@ -39,14 +40,14 @@ public class SplitMergeTool {
class SplitTask extends Task<Boolean>{ class SplitTask extends Task<Boolean>{
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private String saveToPath; private String saveToPath;
private String filePath; private String filePath;
SplitTask(String filePath, String saveToPath){ SplitTask(String filePath, String saveToPath){
this.filePath = filePath; this.filePath = filePath;
this.saveToPath = saveToPath; this.saveToPath = saveToPath;
logPrinter = new LogPrinter(EModule.SPLIT_MERGE_TOOL); logPrinter = Log.getPrinter(EModule.SPLIT_MERGE_TOOL);
} }
@Override @Override
@ -182,14 +183,14 @@ class SplitTask extends Task<Boolean>{
class MergeTask extends Task<Boolean> { class MergeTask extends Task<Boolean> {
private LogPrinter logPrinter; private ILogPrinter logPrinter;
private String saveToPath; private String saveToPath;
private String filePath; private String filePath;
MergeTask(String filePath, String saveToPath) { MergeTask(String filePath, String saveToPath) {
this.filePath = filePath; this.filePath = filePath;
this.saveToPath = saveToPath; this.saveToPath = saveToPath;
logPrinter = new LogPrinter(EModule.SPLIT_MERGE_TOOL); logPrinter = Log.getPrinter(EModule.SPLIT_MERGE_TOOL);
} }
@Override @Override
protected Boolean call() { protected Boolean call() {

View file

@ -8,11 +8,13 @@
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.SVGPath?> <?import javafx.scene.shape.SVGPath?>
<!-- <!--
Steps to roll NXDT functionality back: Steps to roll NXDT functionality back:
* Uncheck 'Disable' on NXDT Tab * Uncheck 'Disable' on NXDT Tab
* Set 'Visible' on NXDT Tab selector (SVGPath container) * Set 'Visible' on NXDT Tab selector (SVGPath container)
--> -->
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.NSLMainController"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.NSLMainController">
<children> <children>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
@ -24,7 +26,7 @@ Steps to roll NXDT functionality back:
<fx:include fx:id="FrontTab" source="FrontTab.fxml" VBox.vgrow="ALWAYS" /> <fx:include fx:id="FrontTab" source="FrontTab.fxml" VBox.vgrow="ALWAYS" />
</content> </content>
<graphic> <graphic>
<SVGPath content="M21,19V17H8V19H21M21,13V11H8V13H21M8,7H21V5H8V7M4,5V7H6V5H4M3,5A1,1 0 0,1 4,4H6A1,1 0 0,1 7,5V7A1,1 0 0,1 6,8H4A1,1 0 0,1 3,7V5M4,11V13H6V11H4M3,11A1,1 0 0,1 4,10H6A1,1 0 0,1 7,11V13A1,1 0 0,1 6,14H4A1,1 0 0,1 3,13V11M4,17V19H6V17H4M3,17A1,1 0 0,1 4,16H6A1,1 0 0,1 7,17V19A1,1 0 0,1 6,20H4A1,1 0 0,1 3,19V17Z" /> <SVGPath content="M 19.953125 -0.00390625 C 19.945025 0.86963499 19.665113 1.3200779 19.117188 1.6679688 C 18.569261 2.0158596 17.688291 2.2107818 16.572266 2.2636719 C 14.340723 2.369428 11.22952 1.9408017 8.0175781 1.7636719 L 8.015625 1.7636719 C 5.8083004 1.6301338 3.850269 1.7145428 2.421875 2.328125 C 1.7074522 2.6350131 1.1147008 3.0945958 0.765625 3.7402344 C 0.41654922 4.3858729 0.3309909 5.1840438 0.50976562 6.0957031 L 0.515625 6.1269531 L 0.52539062 6.1582031 C 0.74516874 6.8214776 1.3043008 7.2559352 1.9550781 7.46875 C 2.6058554 7.6815648 3.3739015 7.7273729 4.2304688 7.703125 C 5.9436032 7.6546292 8.0253788 7.3082908 10.042969 7.1230469 C 12.060559 6.9378029 14.005763 6.9298258 15.349609 7.4511719 C 16.693456 7.972518 17.5 8.8951351 17.5 11 L 13.023438 11 L 10.837891 11 L 1 11 C 0.156581 11 -0.10111662 11.623241 -0.10351562 12.189453 C -0.10591562 12.759114 -0.10321863 13.218366 -0.10351562 13.919922 C -0.10353762 13.969822 -0.10345962 13.990156 -0.10351562 14.042969 C -0.10332363 14.492063 -0.10337263 14.807528 -0.10351562 15.150391 C -0.10359462 15.343113 -0.10438363 15.566512 -0.10351562 15.771484 C -0.10347763 15.861874 -0.10364063 15.971437 -0.10351562 16.064453 C -0.10316562 16.324274 -0.10337563 16.550139 -0.10351562 16.880859 C -0.10353662 16.930759 -0.10345962 16.951094 -0.10351562 17.003906 C -0.10317063 17.257044 -0.10337962 17.473987 -0.10351562 17.794922 C -0.10353762 17.844822 -0.10345962 17.863203 -0.10351562 17.916016 C -0.10380362 18.172294 -0.10461563 18.463892 -0.10351562 18.732422 C -0.10363862 18.825442 -0.10347763 18.935007 -0.10351562 19.025391 C -0.10359462 19.218111 -0.10438363 19.441511 -0.10351562 19.646484 C -0.10337262 19.98934 -0.10332563 20.306746 -0.10351562 20.755859 C -0.10353662 20.805759 -0.10345962 20.826093 -0.10351562 20.878906 C -0.10321564 21.580432 -0.10591562 22.037789 -0.10351562 22.607422 C -0.10111563 23.173608 0.156706 23.796875 1 23.796875 L 10.833984 23.796875 L 13.019531 23.796875 L 22.857422 23.796875 C 23.70084 23.796875 23.958538 23.17361 23.960938 22.607422 C 23.963338 22.037788 23.960642 21.580432 23.960938 20.878906 C 23.960959 20.829006 23.96088 20.808672 23.960938 20.755859 C 23.960749 20.306747 23.960795 19.989341 23.960938 19.646484 C 23.961015 19.453769 23.961803 19.230374 23.960938 19.025391 C 23.9609 18.935011 23.961059 18.825438 23.960938 18.732422 C 23.96059 18.472592 23.960799 18.246723 23.960938 17.916016 C 23.960959 17.866116 23.96088 17.847735 23.960938 17.794922 C 23.960642 17.093366 23.963337 16.63411 23.960938 16.064453 C 23.96106 15.971433 23.960898 15.861868 23.960938 15.771484 C 23.961015 15.578768 23.961803 15.355372 23.960938 15.150391 C 23.960797 14.807528 23.960748 14.492063 23.960938 14.042969 C 23.960959 13.993069 23.96088 13.972735 23.960938 13.919922 C 23.960642 13.218366 23.963337 12.759114 23.960938 12.189453 C 23.958538 11.623242 23.700715 11 22.857422 11 L 18.5 11 C 18.5 8.6048649 17.347496 7.152482 15.710938 6.5175781 C 14.074378 5.8826742 12.017906 5.9371971 9.9511719 6.1269531 C 7.8844382 6.3167092 5.7997949 6.6578708 4.2011719 6.703125 C 3.4018604 6.7257521 2.725744 6.6699978 2.265625 6.5195312 C 1.8171096 6.3728594 1.6083191 6.1804127 1.4941406 5.859375 C 1.3628245 5.141091 1.4300216 4.6115935 1.6445312 4.2148438 C 1.8648981 3.8072608 2.2462454 3.4910124 2.8164062 3.2460938 C 3.9567281 2.7562562 5.8156963 2.6320489 7.9570312 2.7617188 L 7.9589844 2.7617188 C 11.116926 2.9357557 14.220255 3.3773586 16.619141 3.2636719 C 17.818583 3.2068289 18.856796 3.0180713 19.654297 2.5117188 C 20.451798 2.0053661 20.942623 1.130365 20.953125 0.00390625 L 19.953125 -0.00390625 z M 4.4277344 13.271484 L 7 13.271484 L 7 16 L 9.71875 16 L 9.71875 18.5625 L 7 18.5625 L 7 21.291016 L 4.4277344 21.291016 L 4.4277344 18.5625 L 1.7089844 18.5625 L 1.7089844 16 L 4.4277344 16 L 4.4277344 13.271484 z M 20 14 A 1.9161212 1.9161212 0 0 1 21.916016 15.916016 A 1.9161212 1.9161212 0 0 1 20 17.832031 A 1.9161212 1.9161212 0 0 1 18.083984 15.916016 A 1.9161212 1.9161212 0 0 1 20 14 z M 16.421875 17.667969 A 1.9168563 1.9168563 0 0 1 18.337891 19.583984 A 1.9168563 1.9168563 0 0 1 16.421875 21.5 A 1.9168563 1.9168563 0 0 1 14.505859 19.583984 A 1.9168563 1.9168563 0 0 1 16.421875 17.667969 z " />
</graphic> </graphic>
</Tab> </Tab>
<Tab closable="false"> <Tab closable="false">