mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-05-18 17:25:21 -04:00
Add GPLv3+ disclaimers. UsbConnect and TinFoil classes refactoring (trying to make clear code + reduce verbose output).
This commit is contained in:
parent
9693d98db2
commit
272702f043
39 changed files with 999 additions and 382 deletions
src/main/java/nsusbloader/COM/USB
|
@ -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.COM.USB;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
|
@ -18,17 +36,7 @@ public class UsbCommunications extends Task<Void> {
|
|||
private LinkedHashMap<String, File> nspMap;
|
||||
private String protocol;
|
||||
private boolean nspFilterForGl;
|
||||
/*
|
||||
Ok, here is a story. We will pass to NS only file names, not full path. => see nspMap where 'key' is a file name.
|
||||
File name itself should not be greater then 512 bytes, but in real world it's limited by OS to something like 256 bytes.
|
||||
For sure, there could be FS that supports more then 256 and even more then 512 bytes. So if user decides to set name greater then 512 bytes, everything will ruin.
|
||||
There is no extra validations for this situation.
|
||||
Why we poking around 512 bytes? Because it's the maximum size of byte-array that USB endpoind of NS could return. And in runtime it returns the filename.
|
||||
Therefore, the file name shouldn't be greater then 512. If file name + path-to-file is greater then 512 bytes, we can handle it: sending only file name instead of full path.
|
||||
|
||||
Since this application let user an ability (theoretically) to choose same files in different folders, the latest selected file will be added to the list and handled correctly.
|
||||
I have no idea why he/she will make a decision to do that. Just in case, we're good in this point.
|
||||
*/
|
||||
public UsbCommunications(List<File> nspList, String protocol, boolean filterNspFilesOnlyForGl){
|
||||
this.protocol = protocol;
|
||||
this.nspFilterForGl = filterNspFilesOnlyForGl;
|
||||
|
@ -40,9 +48,9 @@ public class UsbCommunications extends Task<Void> {
|
|||
|
||||
@Override
|
||||
protected Void call() {
|
||||
logPrinter.print("\tStart chain", EMsgType.INFO);
|
||||
logPrinter.print("\tStart", EMsgType.INFO);
|
||||
|
||||
UsbConnect usbConnect = new UsbConnect(logPrinter, false);
|
||||
UsbConnect usbConnect = UsbConnect.connectHomebrewMode(logPrinter);
|
||||
|
||||
if (! usbConnect.isConnected()){
|
||||
close(EFileStatus.FAILED);
|
||||
|
@ -80,7 +88,7 @@ public class UsbCommunications extends Task<Void> {
|
|||
*/
|
||||
private void close(EFileStatus status){
|
||||
logPrinter.update(nspMap, status);
|
||||
logPrinter.print("\tEnd chain", EMsgType.INFO);
|
||||
logPrinter.print("\tEnd", EMsgType.INFO);
|
||||
logPrinter.close();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue