diff --git a/.classpath b/.classpath index 2bf671d..4174765 100644 --- a/.classpath +++ b/.classpath @@ -6,5 +6,6 @@ + diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..b42b859 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/application/ diff --git a/bin/application/DBController.class b/bin/application/DBController.class index 6a474fe..9f604cf 100644 Binary files a/bin/application/DBController.class and b/bin/application/DBController.class differ diff --git a/bin/application/Main.class b/bin/application/Main.class index 72dfc72..10dfb0c 100644 Binary files a/bin/application/Main.class and b/bin/application/Main.class differ diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index 8e46a03..f602b41 100644 Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class index 11fe4aa..fba7c04 100644 Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class index 4eabe31..2b78f19 100644 Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class index c9da13f..f00482b 100644 Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ diff --git a/bin/application/MainWindowController$5.class b/bin/application/MainWindowController$5.class index 22237c1..4726153 100644 Binary files a/bin/application/MainWindowController$5.class and b/bin/application/MainWindowController$5.class differ diff --git a/bin/application/MainWindowController$6.class b/bin/application/MainWindowController$6.class index 20d20b6..c1b2b09 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index 21456a4..117bf7a 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index 97cb824..433dd72 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/bin/application/updater.class b/bin/application/updater.class index fd87d6d..047b402 100644 Binary files a/bin/application/updater.class and b/bin/application/updater.class differ diff --git a/bin/libraries/commons-io-2.5.jar b/bin/libraries/commons-io-2.5.jar new file mode 100644 index 0000000..107b061 Binary files /dev/null and b/bin/libraries/commons-io-2.5.jar differ diff --git a/src/application/Main.java b/src/application/Main.java index 9b7f746..1be3727 100644 --- a/src/application/Main.java +++ b/src/application/Main.java @@ -43,6 +43,7 @@ public class Main extends Application { Stage primaryStage; private String path; + String currentWorkingDirectory; // private String streamingPathWin = System.getProperty("user.home") + "\\Documents\\HomeFlix"; // private String streamingPathLinux = System.getProperty("user.home") + "/HomeFlix"; private String COLOR = "ee3523"; @@ -60,7 +61,8 @@ public class Main extends Application { private String dirLinux = System.getProperty("user.home") + "/HomeFlix"; //Linux: /home/"User"/HomeFlix @Override - public void start(Stage primaryStage) { + public void start(Stage primaryStage) throws IOException { + currentWorkingDirectory = new java.io.File( "." ).getCanonicalPath(); this.primaryStage = primaryStage; mainWindow(); } @@ -78,6 +80,7 @@ public class Main extends Application { mainWindowController = loader.getController(); //Link of FXMLController and controller class mainWindowController.setAutoUpdate(AUTO_UPDATE); //set auto-update + mainWindowController.setCurrentWorkingDirectory(currentWorkingDirectory); mainWindowController.setMain(this); //call setMain /**Linux else Windows, check if directory & config exist diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index 67cd94c..c4d7998 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -183,7 +183,7 @@ public class MainWindowController { private boolean autoUpdate = false; static boolean firststart = false; private int hashA = -2055934614; - private String version = "0.5.0"; + private String version = "0.5.1"; private String buildNumber = "121"; private String versionName = "plasma cow"; private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt"; @@ -204,6 +204,7 @@ public class MainWindowController { private String infoText; private String linuxBugText; private String vlcNotInstalled; + private String currentWorkingDirectory; private String path; private String streamingPath; private String color; @@ -1137,4 +1138,12 @@ public class MainWindowController { public String getMode(){ return mode; } + + public String getCurrentWorkingDirectory() { + return currentWorkingDirectory; + } + + public void setCurrentWorkingDirectory(String currentWorkingDirectory) { + this.currentWorkingDirectory = currentWorkingDirectory; + } } diff --git a/src/application/updater.java b/src/application/updater.java index 241389c..32aa8c9 100644 --- a/src/application/updater.java +++ b/src/application/updater.java @@ -5,16 +5,18 @@ package application; import java.io.BufferedReader; -import java.io.FileOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.net.HttpURLConnection; import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; +import javax.swing.ProgressMonitor; +import javax.swing.ProgressMonitorInputStream; + +import org.apache.commons.io.FileUtils; import javafx.application.Platform; -//TODO rework the process after the update is downloaded, need to replace the old config.xml public class updater extends Thread{ private MainWindowController mainWindowController; @@ -60,15 +62,24 @@ public class updater extends Thread{ }); System.out.println("update available"); try { - URL website; + //get the download-Data URL URL downloadURL = new URL(downloadLink); BufferedReader in = new BufferedReader(new InputStreamReader(downloadURL.openStream())); String updateDataURL = in.readLine(); - website = new URL(updateDataURL); //Update URL - ReadableByteChannel rbc = Channels.newChannel(website.openStream()); //open new Stream/Channel - FileOutputStream fos = new FileOutputStream("ProjectHomeFlix.jar"); //new FileOutputStream for ProjectHomeFLix.jar - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); //gets file from 0 to max size - fos.close(); //close fos (extrem wichtig!) + + //open new Http connection, ProgressMonitorInputStream for downloading the data + HttpURLConnection conn = (HttpURLConnection) new URL(updateDataURL).openConnection(); + ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", conn.getInputStream()); + ProgressMonitor pm = pmis.getProgressMonitor(); + pm.setMillisToDecideToPopup(0); + pm.setMillisToPopup(0); + pm.setMinimum(0);// tell the progress bar that we start at the beginning of the stream + pm.setMaximum(conn.getContentLength());// tell the progress bar the total number of bytes we are going to read. + FileUtils.copyInputStreamToFile(pmis, new File("ProjectHomeFlix.jar")); + + + //need to check if the old config file is compatible TODO + Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again System.exit(0); //finishes itself } catch (IOException e) { diff --git a/src/libraries/commons-io-2.5.jar b/src/libraries/commons-io-2.5.jar new file mode 100644 index 0000000..107b061 Binary files /dev/null and b/src/libraries/commons-io-2.5.jar differ