Update NXDT part

Add NXDT CLI support
Update MessagesConsumer
This commit is contained in:
Dmitry Isaenko 2020-07-07 15:02:37 +03:00
parent 6100a721af
commit 96e85056dd
18 changed files with 198 additions and 56 deletions

View file

@ -57,19 +57,27 @@ public class CommandLineInterface {
return;
}
if (cli.hasOption("n") || cli.hasOption("tfn")){
final String[] tfnArguments = cli.getOptionValues("tfn");
new TinfoilNet(tfnArguments);
final String[] arguments = cli.getOptionValues("tfn");
new TinfoilNet(arguments);
return;
}
if (cli.hasOption("t") || cli.hasOption("tinfoil")){
final String[] tfArguments = cli.getOptionValues("tinfoil");
new TinfoilUsb(tfArguments);
final String[] arguments = cli.getOptionValues("tinfoil");
new TinfoilUsb(arguments);
return;
}
if (cli.hasOption("g") || cli.hasOption("goldleaf")){
final String[] glArguments = cli.getOptionValues("goldleaf");
new GoldLeaf(glArguments);
final String[] arguments = cli.getOptionValues("goldleaf");
new GoldLeaf(arguments);
return;
}
/*
if (cli.hasOption("x") || cli.hasOption("nxdt")){
final String[] arguments = cli.getOptionValues("nxdt");
new NXDT(arguments);
return;
}
*/
}
catch (ParseException pe){
System.out.println(pe.getLocalizedMessage() +
@ -139,6 +147,15 @@ public class CommandLineInterface {
.hasArgs()
.argName("...")
.build();
/* nxdumptool */
/*
final Option nxdtOption = Option.builder("x")
.longOpt("nxdt")
.desc("Handle nxdumptool connections.")
.hasArg()
.argName("DIRECTORY")
.build();
*/
final OptionGroup group = new OptionGroup();
group.addOption(rcmOption);
@ -148,6 +165,7 @@ public class CommandLineInterface {
group.addOption(helpOption);
group.addOption(tinfoilOption);
group.addOption(glOption);
//group.addOption(nxdtOption);
options.addOptionGroup(group);

View file

@ -1,6 +1,24 @@
/*
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.cli;
import nsusbloader.COM.ICommunications;
import nsusbloader.COM.INSTask;
import nsusbloader.COM.USB.UsbCommunications;
import nsusbloader.Controllers.SettingsController;
@ -51,8 +69,8 @@ public class GoldLeaf {
+ "\tns-usbloader -g ver=<arg1> [filter] FILE1 ...\n"
+ "\tns-usbloader --goldleaf ver=<arg1> [filter] FILE1 ..."
+ "\n\nOption:"
+ "\n\tver=<goldleaf_version>\tDefine GoldLeaf version (mandatory)\n\n"
+ "\n\tfilter\t\nShow only *.nsp in GoldLeaf (optional)\n\n"
+ "\n\tver=<goldleaf_version>\tDefine GoldLeaf version (mandatory)"
+ "\n\tfilter\t\t\tShow only *.nsp in GoldLeaf (optional)\n\n"
+ getGlSupportedVersions());
}
private String getGlSupportedVersions(){
@ -107,7 +125,7 @@ public class GoldLeaf {
}
public void runGoldLeafBackend() throws InterruptedException {
ICommunications task = new UsbCommunications(filesList,
INSTask task = new UsbCommunications(filesList,
"GoldLeaf"+goldLeafVersion,
filterForNsp);
Thread thread = new Thread(task);

View file

@ -1,3 +1,21 @@
/*
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.cli;
public class IncorrectSetupException extends Exception {

View file

@ -0,0 +1,58 @@
/*
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.cli;
import nsusbloader.Utilities.nxdumptool.NxdtTask;
import java.io.File;
public class NXDT {
private final String[] arguments;
private String saveTo;
public NXDT(String[] arguments) throws InterruptedException, IncorrectSetupException{
this.arguments = arguments;
parseArgument();
runBackend();
}
private void parseArgument() throws IncorrectSetupException{
final File file = new File(arguments[0]);
if (! file.exists()){
throw new IncorrectSetupException("Directory does not exist.\n" +
"Try 'ns-usbloader -h' for more information.");
}
if (file.isFile()){
throw new IncorrectSetupException("Argument is file while directory expected.\n" +
"Try 'ns-usbloader -h' for more information.");
}
saveTo = arguments[0];
}
private void runBackend() throws InterruptedException{
NxdtTask nxdtTask = new NxdtTask(saveTo);
Thread thread = new Thread(nxdtTask);
thread.start();
thread.join();
}
}

View file

@ -1,6 +1,24 @@
/*
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.cli;
import nsusbloader.COM.ICommunications;
import nsusbloader.COM.INSTask;
import nsusbloader.COM.USB.UsbCommunications;
import java.io.File;
@ -43,7 +61,7 @@ public class TinfoilUsb {
}
private void runTinfoilBackend() throws InterruptedException{
ICommunications task = new UsbCommunications(filesList, "TinFoil", false);
INSTask task = new UsbCommunications(filesList, "TinFoil", false);
Thread thread = new Thread(task);
thread.start();
thread.join();