fixed bug #6
fixed a bug that prevented homeflix from starting under linux
This commit is contained in:
		| @ -49,6 +49,11 @@ public class DBController { | ||||
| 	Connection connection = null; | ||||
|  | ||||
| 	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 { | ||||
| 			// create a database connection | ||||
| 			connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH); | ||||
| @ -181,7 +186,7 @@ public class DBController { | ||||
| 						ps.close(); | ||||
| 						psS.close(); | ||||
| 					}catch (SQLException ea) {  | ||||
| 						System.err.println("Konnte nicht ausgef<65>hrt werden");  | ||||
| 						System.err.println("Konnte nicht ausgef<65>hrt werden");  | ||||
| 						ea.printStackTrace();  | ||||
| 					} | ||||
| 				}else { | ||||
| @ -322,7 +327,7 @@ public class DBController { | ||||
| 					String titel = items.get(i).asObject().getString("titel",""); | ||||
| 					 | ||||
| 					if(streamURL.equals(filmsStreamURL.get(b))){ | ||||
| 						System.out.println("hinzuf<EFBFBD>gen \""+titel+"\""); | ||||
| 						System.out.println("hinzuf<EFBFBD>gen \""+titel+"\""); | ||||
| 						 | ||||
| 						ps.setInt(1, items.get(i).asObject().getInt("year", 0)); | ||||
| 						ps.setInt(2, items.get(i).asObject().getInt("season", 0)); | ||||
| @ -345,7 +350,7 @@ public class DBController { | ||||
| 	} | ||||
| 	 | ||||
| 	void ausgeben(){ | ||||
| 	System.out.println("Eintr<EFBFBD>ge ausgeben ... \n");  | ||||
| 	System.out.println("Eintr<EFBFBD>ge ausgeben ... \n");  | ||||
| 	try {  | ||||
| 		Statement stmt = connection.createStatement();  | ||||
| 		ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");  | ||||
|  | ||||
| @ -46,14 +46,18 @@ public class Main extends Application { | ||||
| 	 | ||||
| 	public Stage primaryStage; | ||||
| 	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 autoUpdate = "0"; | ||||
| 	private String mode = "local";	//local or streaming | ||||
| 	private double size = 12; | ||||
| 	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 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 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 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(); | ||||
| 	private MainWindowController mainWindowController; | ||||
| 	 | ||||
| @ -79,33 +83,68 @@ public class Main extends Application { | ||||
| 		mainWindowController.setMain(this);	//call setMain | ||||
| 		 | ||||
| 		//dir exists -> check config.xml | ||||
| 		if(dir.exists() == true){ | ||||
| 			if (file.exists() != true) { | ||||
| 				mainWindowController.setPath(firstStart()); | ||||
| 				mainWindowController.setStreamingPath(streamingPath); | ||||
| 				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 | ||||
| 		if(System.getProperty("os.name").equals("Linux")){ | ||||
| 			if(dirLinux.exists() == true){ | ||||
| 				if (fileLinux.exists() != true) { | ||||
| 					mainWindowController.setPath(firstStart()); | ||||
| 					if(System.getProperty("os.name").equals("Linux")){ | ||||
| 						mainWindowController.setStreamingPath(streamingPathLinux); | ||||
| 					}else{ | ||||
| 						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 | ||||
| 				}else{ | ||||
| 					loadSettings(); | ||||
| 				}	 | ||||
| 			}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{ | ||||
| 		dir.mkdir(); | ||||
| 		mainWindowController.setPath(firstStart()); | ||||
| 		mainWindowController.setStreamingPath(streamingPath); | ||||
| 		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 | ||||
| 			if(dirWin.exists() == true){ | ||||
| 				if (fileWin.exists() != true) { | ||||
| 					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 | ||||
| 				}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(); | ||||
| @ -117,7 +156,7 @@ public class Main extends Application { | ||||
| 		mainWindowController.dbController.createDatabase(); //creating the database | ||||
| 		mainWindowController.dbController.loadData(); 	//loading data from database to mainWindowController  | ||||
| 		 | ||||
| //		mainWindowController.loadData();	//l<>d die Daten im Controller | ||||
| //		mainWindowController.loadData();	//l<>d die Daten im Controller | ||||
| 		mainWindowController.addDataUI(); | ||||
| 		 | ||||
| 		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<>r den erstmaligen Start | ||||
| 	private String firstStart(){ | ||||
| 		Alert alert = new Alert(AlertType.CONFIRMATION);	//new alert with filechooser | ||||
| 		alert.setTitle("Project HomeFlix"); | ||||
| 		alert.setHeaderText("Es ist kein Stammverzeichniss f<>r Filme angegeben!");	//TODO translate | ||||
| 		alert.setHeaderText("Es ist kein Stammverzeichniss f<>r Filme angegeben!");	//TODO translate | ||||
| 		alert.setContentText("Stammverzeichniss angeben?"); | ||||
|  | ||||
| 		Optional<ButtonType> result = alert.showAndWait(); | ||||
| @ -149,13 +188,21 @@ public class Main extends Application { | ||||
| 		return path; | ||||
| 	} | ||||
| 	 | ||||
| 	//l<EFBFBD>dt die einstellungen aus der XML | ||||
| 	//lädt die einstellungen aus der XML | ||||
| 	public void loadSettings(){ | ||||
| 		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); | ||||
| 			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"); | ||||
| 			size = Double.parseDouble(props.getProperty("size")); | ||||
| 			autoUpdate = props.getProperty("autoUpdate"); | ||||
|  | ||||
| @ -184,12 +184,14 @@ public class MainWindowController { | ||||
| 	private boolean streamingSettingsTrue = false; | ||||
| 	private int hashA = -2055934614; | ||||
| 	private String version = "0.4.99"; | ||||
| 	private String buildNumber = "110"; | ||||
| 	private String buildNumber = "112"; | ||||
| 	private String versionName = "plasma cow (pre Release)"; | ||||
| 	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 File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix");	 | ||||
| 	private File file = new File(dir + "/config.xml");	 | ||||
| 	private File dirWin = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); | ||||
| 	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 errorUpdateV; | ||||
| @ -936,6 +938,7 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	//saves the Settings | ||||
| 	public void saveSettings(){ | ||||
| 		OutputStream outputStream;	//new outputstream | ||||
| 		try { | ||||
| 			props.setProperty("path", getPath());	//writes path into property | ||||
| 			props.setProperty("color", getColor()); | ||||
| @ -945,7 +948,11 @@ public class MainWindowController { | ||||
| 			props.setProperty("streamingPath", getStreamingPath()); | ||||
| 			props.setProperty("mode", getMode()); | ||||
| 			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 | ||||
| 			outputStream.close(); | ||||
| 		} catch (IOException e) { | ||||
| @ -956,8 +963,13 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	//loads the Settings | ||||
| 	public void loadSettings(){ | ||||
| 		InputStream inputStream; | ||||
| 		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 | ||||
| 			path = props.getProperty("path");	//reads path from property | ||||
| 			streamingPath = props.getProperty("streamingPath"); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user