|
@@ -1,6 +1,11 @@
|
|
package de.nplusc.izc.senabitwiggler;
|
|
package de.nplusc.izc.senabitwiggler;
|
|
|
|
|
|
|
|
+import org.yaml.snakeyaml.DumperOptions;
|
|
|
|
+import org.yaml.snakeyaml.TypeDescription;
|
|
import org.yaml.snakeyaml.Yaml;
|
|
import org.yaml.snakeyaml.Yaml;
|
|
|
|
+import org.yaml.snakeyaml.constructor.Constructor;
|
|
|
|
+import org.yaml.snakeyaml.nodes.Tag;
|
|
|
|
+import org.yaml.snakeyaml.representer.Representer;
|
|
|
|
|
|
import javax.swing.plaf.nimbus.State;
|
|
import javax.swing.plaf.nimbus.State;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
@@ -20,15 +25,22 @@ public class FirmwareAutoDumper
|
|
{
|
|
{
|
|
outfolder_base=outfolder;
|
|
outfolder_base=outfolder;
|
|
try{
|
|
try{
|
|
|
|
+ Representer representer = new Representer();
|
|
|
|
+ representer.addClassTag(Firmware.class, new Tag("!FW"));
|
|
|
|
+ representer.addClassTag(FirmwareVersion.class, new Tag("!FWV"));
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
- Yaml y = new Yaml();
|
|
|
|
|
|
+ Yaml y = new Yaml(representer, new DumperOptions());
|
|
|
|
|
|
if(statefile.exists())
|
|
if(statefile.exists())
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
- state = (Statefile) y.load(new FileReader(statefile));
|
|
|
|
|
|
+ Constructor constructor = new Constructor();
|
|
|
|
+ constructor.addTypeDescription(new TypeDescription(Firmware.class, "!FW"));
|
|
|
|
+ constructor.addTypeDescription(new TypeDescription(FirmwareVersion.class, "!FWV"));
|
|
|
|
+
|
|
|
|
+ Yaml internal = new Yaml(constructor);
|
|
|
|
+ state = (Statefile) internal.load(new FileReader(statefile));
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
System.err.println("Hurz");
|
|
System.err.println("Hurz");
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -47,7 +59,7 @@ public class FirmwareAutoDumper
|
|
"http://firmware.sena.com/senabluetoothmanager/Firmware"
|
|
"http://firmware.sena.com/senabluetoothmanager/Firmware"
|
|
);
|
|
);
|
|
|
|
|
|
- BufferedReader br = new BufferedReader(new FileReader(new File(outfolder_tmp,"firmware")));
|
|
|
|
|
|
+ BufferedReader br = new BufferedReader(new FileReader(new File(outfolder_tmp,"Firmware")));
|
|
final HashMap<String,String> basenamelookup = new HashMap<>();
|
|
final HashMap<String,String> basenamelookup = new HashMap<>();
|
|
// filename --> real basename
|
|
// filename --> real basename
|
|
br.lines().forEach((line)->
|
|
br.lines().forEach((line)->
|
|
@@ -61,8 +73,7 @@ public class FirmwareAutoDumper
|
|
FWBAsename = linesplitted[0]+"-"+linesplitted[2];
|
|
FWBAsename = linesplitted[0]+"-"+linesplitted[2];
|
|
FWFileName = linesplitted[3];
|
|
FWFileName = linesplitted[3];
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(linesplitted.length==3)
|
|
|
|
|
|
+ else if(linesplitted.length==3)
|
|
{
|
|
{
|
|
FWBAsename = linesplitted[0]+"-NOLNG";
|
|
FWBAsename = linesplitted[0]+"-NOLNG";
|
|
FWFileName = linesplitted[2];
|
|
FWFileName = linesplitted[2];
|
|
@@ -71,11 +82,15 @@ public class FirmwareAutoDumper
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
if(basenamelookup.containsKey(FWFileName))
|
|
if(basenamelookup.containsKey(FWFileName))
|
|
{
|
|
{
|
|
return; //languageless file, no need to handle multiple times.
|
|
return; //languageless file, no need to handle multiple times.
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ basenamelookup.put(FWFileName,FWBAsename);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
if(!state.getFirmwares().containsKey(FWBAsename))
|
|
if(!state.getFirmwares().containsKey(FWBAsename))
|
|
@@ -222,7 +237,7 @@ public class FirmwareAutoDumper
|
|
f.setMinor(minor);
|
|
f.setMinor(minor);
|
|
f.setPatch(patch);
|
|
f.setPatch(patch);
|
|
File downloadFolderBase = new File(outfolder_base,"downloadstage");
|
|
File downloadFolderBase = new File(outfolder_base,"downloadstage");
|
|
- if(true) return f;
|
|
|
|
|
|
+ //if(true) return f;
|
|
Utils.runTool(downloadFolderBase,
|
|
Utils.runTool(downloadFolderBase,
|
|
"wget",
|
|
"wget",
|
|
"http://firmware.sena.com/senabluetoothmanager/"+fwname
|
|
"http://firmware.sena.com/senabluetoothmanager/"+fwname
|