fixed a bug that prevented homeflix from starting under linux
This commit is contained in:
Jannik 2017-02-05 17:14:34 +01:00 committed by GitHub
parent 5dbf5278c9
commit 1801723bdb
3 changed files with 106 additions and 42 deletions

View File

@ -49,6 +49,11 @@ public class DBController {
Connection connection = null; Connection connection = null;
public void main() { public void main() {
if (System.getProperty("os.name").equals("Linux")) {
DB_PATH = System.getProperty("user.home") + "/HomeFlix/Homeflix.db";
}else{
DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db";
}
try { try {
// create a database connection // create a database connection
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH); connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
@ -181,7 +186,7 @@ public class DBController {
ps.close(); ps.close();
psS.close(); psS.close();
}catch (SQLException ea) { }catch (SQLException ea) {
System.err.println("Konnte nicht ausgeführt werden"); System.err.println("Konnte nicht ausgef<EFBFBD>hrt werden");
ea.printStackTrace(); ea.printStackTrace();
} }
}else { }else {
@ -322,7 +327,7 @@ public class DBController {
String titel = items.get(i).asObject().getString("titel",""); String titel = items.get(i).asObject().getString("titel","");
if(streamURL.equals(filmsStreamURL.get(b))){ if(streamURL.equals(filmsStreamURL.get(b))){
System.out.println("hinzufügen \""+titel+"\""); System.out.println("hinzuf<EFBFBD>gen \""+titel+"\"");
ps.setInt(1, items.get(i).asObject().getInt("year", 0)); ps.setInt(1, items.get(i).asObject().getInt("year", 0));
ps.setInt(2, items.get(i).asObject().getInt("season", 0)); ps.setInt(2, items.get(i).asObject().getInt("season", 0));
@ -345,7 +350,7 @@ public class DBController {
} }
void ausgeben(){ void ausgeben(){
System.out.println("Einträge ausgeben ... \n"); System.out.println("Eintr<EFBFBD>ge ausgeben ... \n");
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");

View File

@ -46,14 +46,18 @@ public class Main extends Application {
public Stage primaryStage; public Stage primaryStage;
private String path; private String path;
private String streamingPath = System.getProperty("user.home") + "\\Documents\\HomeFlix"; private InputStream inputStream;
private String streamingPathWin = System.getProperty("user.home") + "\\Documents\\HomeFlix";
private String streamingPathLinux = System.getProperty("user.home") + "/HomeFlix";
private String color = "ee3523"; private String color = "ee3523";
private String autoUpdate = "0"; private String autoUpdate = "0";
private String mode = "local"; //local or streaming private String mode = "local"; //local or streaming
private double size = 12; private double size = 12;
private int local = 0; private int local = 0;
private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); //Windows: C:/Users/"User"/Documents/HomeFlix OSX: not tested yet Linux: not tested yet(shalt not work!) private File dirWin = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); //Windows: C:/Users/"User"/Documents/HomeFlix OSX: not tested yet Linux: not tested yet(shalt not work!)
private File file = new File(dir + "/config.xml"); //Windows: C:/Users/"User"/Documents/HomeFlix/config.xml OSX: not tested yet Linux: not tested yet(shalt not work!) private File dirLinux = new File(System.getProperty("user.home") + "/HomeFlix");
private File fileWin = new File(dirWin + "/config.xml"); //Windows: C:/Users/"User"/Documents/HomeFlix/config.xml OSX: not tested yet Linux: not tested yet(shalt not work!)
private File fileLinux = new File(dirLinux + "/config.xml");
Properties props = new Properties(); Properties props = new Properties();
private MainWindowController mainWindowController; private MainWindowController mainWindowController;
@ -79,33 +83,68 @@ public class Main extends Application {
mainWindowController.setMain(this); //call setMain mainWindowController.setMain(this); //call setMain
//dir exists -> check config.xml //dir exists -> check config.xml
if(dir.exists() == true){ if(System.getProperty("os.name").equals("Linux")){
if (file.exists() != true) { if(dirLinux.exists() == true){
mainWindowController.setPath(firstStart()); if (fileLinux.exists() != true) {
mainWindowController.setStreamingPath(streamingPath); mainWindowController.setPath(firstStart());
mainWindowController.setColor(color); if(System.getProperty("os.name").equals("Linux")){
mainWindowController.setSize(size); mainWindowController.setStreamingPath(streamingPathLinux);
mainWindowController.setAutoUpdate(autoUpdate); }else{
mainWindowController.setLoaclUI(local); mainWindowController.setStreamingPath(streamingPathWin);
mainWindowController.setMode(mode); }
mainWindowController.saveSettings(); mainWindowController.setColor(color);
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs) mainWindowController.setSize(size);
System.exit(0); //finishes itself mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setLoaclUI(local);
mainWindowController.setMode(mode);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}else{
loadSettings();
}
}else{ }else{
loadSettings(); dirLinux.mkdir();
} mainWindowController.setPath(firstStart());
mainWindowController.setStreamingPath(streamingPathLinux);
mainWindowController.setColor(color);
mainWindowController.setSize(size);
mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setLoaclUI(local);
mainWindowController.setMode(mode);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}
}else{ }else{
dir.mkdir(); if(dirWin.exists() == true){
mainWindowController.setPath(firstStart()); if (fileWin.exists() != true) {
mainWindowController.setStreamingPath(streamingPath); mainWindowController.setPath(firstStart());
mainWindowController.setColor(color); mainWindowController.setStreamingPath(streamingPathWin);
mainWindowController.setSize(size); mainWindowController.setColor(color);
mainWindowController.setAutoUpdate(autoUpdate); mainWindowController.setSize(size);
mainWindowController.setLoaclUI(local); mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setMode(mode); mainWindowController.setLoaclUI(local);
mainWindowController.saveSettings(); mainWindowController.setMode(mode);
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs) mainWindowController.saveSettings();
System.exit(0); //finishes itself Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}else{
loadSettings();
}
}else{
dirWin.mkdir();
mainWindowController.setPath(firstStart());
mainWindowController.setStreamingPath(streamingPathWin);
mainWindowController.setColor(color);
mainWindowController.setSize(size);
mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setLoaclUI(local);
mainWindowController.setMode(mode);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}
} }
mainWindowController.loadStreamingSettings(); mainWindowController.loadStreamingSettings();
@ -117,7 +156,7 @@ public class Main extends Application {
mainWindowController.dbController.createDatabase(); //creating the database mainWindowController.dbController.createDatabase(); //creating the database
mainWindowController.dbController.loadData(); //loading data from database to mainWindowController mainWindowController.dbController.loadData(); //loading data from database to mainWindowController
// mainWindowController.loadData(); //läd die Daten im Controller // mainWindowController.loadData(); //l<EFBFBD>d die Daten im Controller
mainWindowController.addDataUI(); mainWindowController.addDataUI();
Scene scene = new Scene(pane); //create new scene, append pane to scene Scene scene = new Scene(pane); //create new scene, append pane to scene
@ -129,11 +168,11 @@ public class Main extends Application {
} }
} }
//methode für den erstmaligen Start //methode f<EFBFBD>r den erstmaligen Start
private String firstStart(){ private String firstStart(){
Alert alert = new Alert(AlertType.CONFIRMATION); //new alert with filechooser Alert alert = new Alert(AlertType.CONFIRMATION); //new alert with filechooser
alert.setTitle("Project HomeFlix"); alert.setTitle("Project HomeFlix");
alert.setHeaderText("Es ist kein Stammverzeichniss für Filme angegeben!"); //TODO translate alert.setHeaderText("Es ist kein Stammverzeichniss f<EFBFBD>r Filme angegeben!"); //TODO translate
alert.setContentText("Stammverzeichniss angeben?"); alert.setContentText("Stammverzeichniss angeben?");
Optional<ButtonType> result = alert.showAndWait(); Optional<ButtonType> result = alert.showAndWait();
@ -149,13 +188,21 @@ public class Main extends Application {
return path; return path;
} }
//lädt die einstellungen aus der XML //lädt die einstellungen aus der XML
public void loadSettings(){ public void loadSettings(){
try { try {
InputStream inputStream = new FileInputStream(file); if(System.getProperty("os.name").equals("Linux")){
inputStream = new FileInputStream(fileLinux);
}else{
inputStream = new FileInputStream(fileWin);
}
props.loadFromXML(inputStream); props.loadFromXML(inputStream);
path = props.getProperty("path"); //setzt Propselement in Pfad path = props.getProperty("path"); //setzt Propselement in Pfad
streamingPath = props.getProperty("streamingPath"); if(System.getProperty("os.name").equals("Linux")){
streamingPathLinux = props.getProperty("streamingPath");
}else{
streamingPathWin = props.getProperty("streamingPath");
}
color = props.getProperty("color"); color = props.getProperty("color");
size = Double.parseDouble(props.getProperty("size")); size = Double.parseDouble(props.getProperty("size"));
autoUpdate = props.getProperty("autoUpdate"); autoUpdate = props.getProperty("autoUpdate");

View File

@ -184,12 +184,14 @@ public class MainWindowController {
private boolean streamingSettingsTrue = false; private boolean streamingSettingsTrue = false;
private int hashA = -2055934614; private int hashA = -2055934614;
private String version = "0.4.99"; private String version = "0.4.99";
private String buildNumber = "110"; private String buildNumber = "112";
private String versionName = "plasma cow (pre Release)"; private String versionName = "plasma cow (pre Release)";
private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt"; private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt";
private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt"; private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt";
private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); private File dirWin = new File(System.getProperty("user.home") + "/Documents/HomeFlix");
private File file = new File(dir + "/config.xml"); private File dirLinux = new File(System.getProperty("user.home") + "/HomeFlix");
private File fileWin = new File(dirWin + "/config.xml");
private File fileLinux = new File(dirLinux + "/config.xml");
String errorUpdateD; String errorUpdateD;
String errorUpdateV; String errorUpdateV;
@ -936,6 +938,7 @@ public class MainWindowController {
//saves the Settings //saves the Settings
public void saveSettings(){ public void saveSettings(){
OutputStream outputStream; //new outputstream
try { try {
props.setProperty("path", getPath()); //writes path into property props.setProperty("path", getPath()); //writes path into property
props.setProperty("color", getColor()); props.setProperty("color", getColor());
@ -945,7 +948,11 @@ public class MainWindowController {
props.setProperty("streamingPath", getStreamingPath()); props.setProperty("streamingPath", getStreamingPath());
props.setProperty("mode", getMode()); props.setProperty("mode", getMode());
props.setProperty("ratingSortType", columnRating.getSortType().toString()); props.setProperty("ratingSortType", columnRating.getSortType().toString());
OutputStream outputStream = new FileOutputStream(file); //new outputstream if(System.getProperty("os.name").equals("Linux")){
outputStream = new FileOutputStream(fileLinux);
}else{
outputStream = new FileOutputStream(fileWin);
}
props.storeToXML(outputStream, "Project HomeFlix settings"); //writes new .xml props.storeToXML(outputStream, "Project HomeFlix settings"); //writes new .xml
outputStream.close(); outputStream.close();
} catch (IOException e) { } catch (IOException e) {
@ -956,8 +963,13 @@ public class MainWindowController {
//loads the Settings //loads the Settings
public void loadSettings(){ public void loadSettings(){
InputStream inputStream;
try { try {
InputStream inputStream = new FileInputStream(file); if(System.getProperty("os.name").equals("Linux")){
inputStream = new FileInputStream(fileLinux);
}else{
inputStream = new FileInputStream(fileWin);
}
props.loadFromXML(inputStream); //new inputstream from .xml props.loadFromXML(inputStream); //new inputstream from .xml
path = props.getProperty("path"); //reads path from property path = props.getProperty("path"); //reads path from property
streamingPath = props.getProperty("streamingPath"); streamingPath = props.getProperty("streamingPath");