forked from developersu/ns-usbloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c21417c
Showing
20 changed files
with
1,904 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pipeline { | ||
agent { | ||
docker { | ||
image 'maven:3-jdk-11' | ||
args '-v /home/docker/jenkins/files/m2:/root/.m2' | ||
} | ||
} | ||
|
||
stages { | ||
stage('Build') { | ||
steps { | ||
sh 'mvn -B -DskipTests clean package' | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
archiveArtifacts artifacts: 'target/*-jar-with-dependencies.jar', onlyIfSuccessful: true | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# NS-USBloader | ||
|
||
NS-USBloader is a PC-side tinfoil NSP USB uploader. Replacement for default usb_install_pc.py | ||
With GUI and cookies. | ||
|
||
## License | ||
|
||
Source code spreads under the GNU General Public License v.3. You can find it in LICENSE file. | ||
|
||
## Used libraries | ||
* OpenJFX https://wiki.openjdk.java.net/display/OpenJFX/Main | ||
* usb4java: https://mvnrepository.com/artifact/org.usb4java/usb4java | ||
|
||
## Tips&tricks | ||
### Add user to udev rules to use NS non-root: | ||
root # vim /etc/udev/rules.d/99-NS.rules | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="3000", GROUP="plugdev" | ||
root # udevadm control --reload-rules && udevadm trigger | ||
|
||
## Known bugs | ||
* Unable to interrupt transmission when libusb awaiting for read event (when user sent NSP list but didn't selected anything on NS). | ||
|
||
## TODO: | ||
- [ ] macOS QA | ||
- [ ] Windows support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>loper</groupId> | ||
<artifactId>NS-USBloader</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
<name>NS-USBloader</name> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-controls</artifactId> | ||
<version>11</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-media</artifactId> | ||
<version>11</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-fxml</artifactId> | ||
<version>11</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/org.usb4java/usb4java --> | ||
<dependency> | ||
<groupId>org.usb4java</groupId> | ||
<artifactId>usb4java</artifactId> | ||
<version>1.3.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>nsusbloader.Main</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> <!-- this is used for inheritance merges --> | ||
<phase>package</phase> <!-- bind to the packaging phase --> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nsusbloader; | ||
|
||
public class Main { | ||
public static void main(String[] args){ NSLMain.main(args); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package nsusbloader; | ||
|
||
class MediatorControl { | ||
private boolean isTransferActive = false; | ||
private NSLMainController applicationController; | ||
|
||
static MediatorControl getInstance(){ | ||
return MediatorControlHold.INSTANCE; | ||
} | ||
|
||
private static class MediatorControlHold { | ||
private static final MediatorControl INSTANCE = new MediatorControl(); | ||
} | ||
void registerController(NSLMainController controller){ | ||
this.applicationController = controller; | ||
} | ||
|
||
synchronized void setTransferActive(boolean state) { | ||
isTransferActive = state; | ||
applicationController.notifyTransmissionStarted(state); | ||
} | ||
synchronized boolean getTransferActive() { | ||
return this.isTransferActive; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package nsusbloader; | ||
|
||
import javafx.animation.AnimationTimer; | ||
import javafx.scene.control.ProgressBar; | ||
import javafx.scene.control.TextArea; | ||
|
||
import java.util.ArrayList; | ||
import java.util.concurrent.BlockingQueue; | ||
|
||
public class MessagesConsumer extends AnimationTimer { | ||
private final BlockingQueue<String> msgQueue; | ||
private final TextArea logsArea; | ||
|
||
private final BlockingQueue<Double> progressQueue; | ||
private final ProgressBar progressBar; | ||
|
||
private boolean isInterrupted; | ||
|
||
MessagesConsumer(BlockingQueue<String> msgQueue, TextArea logsArea, BlockingQueue<Double> progressQueue, ProgressBar progressBar){ | ||
this.msgQueue = msgQueue; | ||
this.logsArea = logsArea; | ||
|
||
this.progressBar = progressBar; | ||
this.progressQueue = progressQueue; | ||
|
||
progressBar.setProgress(0.0); | ||
this.isInterrupted = false; | ||
MediatorControl.getInstance().setTransferActive(true); | ||
} | ||
|
||
@Override | ||
public void handle(long l) { | ||
ArrayList<String> messages = new ArrayList<>(); | ||
int msgRecieved = msgQueue.drainTo(messages); | ||
if (msgRecieved > 0) | ||
messages.forEach(msg -> logsArea.appendText(msg)); | ||
|
||
ArrayList<Double> progress = new ArrayList<>(); | ||
int progressRecieved = progressQueue.drainTo(progress); | ||
if (progressRecieved > 0) | ||
progress.forEach(prg -> progressBar.setProgress(prg)); | ||
|
||
if (isInterrupted) { | ||
MediatorControl.getInstance().setTransferActive(false); | ||
progressBar.setProgress(0.0); | ||
this.stop(); | ||
} | ||
//TODO | ||
} | ||
|
||
void interrupt(){ | ||
this.isInterrupted = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
Name: NSL-USBFoil | ||
@author Dmitry Isaenko | ||
License: GNU GPL v.3 | ||
@see https://github.com/developersu/ | ||
2019, Russia | ||
*/ | ||
package nsusbloader; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.image.Image; | ||
import javafx.stage.Stage; | ||
|
||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
public class NSLMain extends Application { | ||
static final String appVersion = "v0.1-DEVELOPMENT"; | ||
@Override | ||
public void start(Stage primaryStage) throws Exception{ | ||
ResourceBundle rb; | ||
if (Locale.getDefault().getISO3Language().equals("rus")) | ||
rb = ResourceBundle.getBundle("locale", new Locale("ru")); | ||
else | ||
rb = ResourceBundle.getBundle("locale", new Locale("en")); | ||
|
||
// If it's windows, refuse to work | ||
if (System.getProperty("os.name").toLowerCase().startsWith("win")){ | ||
ServiceWindow.getErrorNotification(rb.getString("windowErrorHeader"), rb.getString("windowItsWindowsMessage")); | ||
} | ||
else{ | ||
// If it's not, go ahead | ||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml")); | ||
|
||
loader.setResources(rb); | ||
Parent root = loader.load(); | ||
|
||
primaryStage.getIcons().addAll( | ||
new Image(getClass().getResourceAsStream("/res/app_icon32x32.png")), | ||
new Image(getClass().getResourceAsStream("/res/app_icon48x48.png")), | ||
new Image(getClass().getResourceAsStream("/res/app_icon64x64.png")), | ||
new Image(getClass().getResourceAsStream("/res/app_icon128x128.png")) | ||
); | ||
|
||
primaryStage.setTitle("NS-USBloader"); | ||
primaryStage.setMinWidth(600); | ||
primaryStage.setMinHeight(375); | ||
Scene mainScene = new Scene(root, 800, 400); | ||
mainScene.getStylesheets().add("/res/app.css"); | ||
primaryStage.setScene(mainScene); | ||
primaryStage.show(); | ||
|
||
primaryStage.setOnCloseRequest(e->{ | ||
if (MediatorControl.getInstance().getTransferActive()) | ||
if(! ServiceWindow.getConfirmationWindow(rb.getString("windowTitleConfirmExit"), rb.getString("windowBodyConfirmExit"))) | ||
e.consume(); | ||
}); | ||
} | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
if ((args.length == 1) && (args[0].equals("-v") || args[0].equals("--version"))){ | ||
System.out.println(NSLMain.appVersion); | ||
} | ||
else | ||
launch(args); | ||
} | ||
} |
Oops, something went wrong.