util

Clone or download

Added CheckForUpdates

Modified Files

M pom.xml
+7 −0
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
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>
<modelVersion>4.0.0</modelVersion>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
<artifactId>util</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<url>https://stream-pi.com/</url>
<url>https://stream-pi.com/</url>
<properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>16-ea+7</javafx.version>
<javafx.version>16-ea+7</javafx.version>
<ikonli.version>11.5.0</ikonli.version>
<ikonli.version>11.5.0</ikonli.version>
<source.plugin.version>2.2.1</source.plugin.version>
<source.plugin.version>2.2.1</source.plugin.version>
<javadoc.plugin.version>3.1.0</javadoc.plugin.version>
<javadoc.plugin.version>3.1.0</javadoc.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>org.openjfx</groupId>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
<version>${javafx.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<artifactId>ikonli-javafx</artifactId>
<version>${ikonli.version}</version>
<version>${ikonli.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-fontawesome5-pack</artifactId>
<artifactId>ikonli-fontawesome5-pack</artifactId>
<version>${ikonli.version}</version>
<version>${ikonli.version}</version>
</dependency>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.0</version>
<executions>
<executions>
<execution>
<execution>
<id>test-jar</id>
<id>test-jar</id>
<phase>package</phase>
<phase>package</phase>
<goals>
<goals>
<goal>test-jar</goal>
<goal>test-jar</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.8.1</version>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
<profiles>
<profiles>
<profile>
<profile>
<id>release</id>
<id>release</id>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>2.2.1</version>
<executions>
<executions>
<execution>
<execution>
<id>attach-sources</id>
<id>attach-sources</id>
<goals>
<goals>
<goal>jar-no-fork</goal>
<goal>jar-no-fork</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<version>${javadoc.plugin.version}</version>
<executions>
<executions>
<execution>
<execution>
<id>attach-javadocs</id>
<id>attach-javadocs</id>
<goals>
<goals>
<goal>jar</goal>
<goal>jar</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
<configuration>
<configuration>
<source>8</source>
<source>8</source>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${gpg.plugin.version}</version>
<version>${gpg.plugin.version}</version>
<executions>
<executions>
<execution>
<execution>
<id>sign-artifacts</id>
<id>sign-artifacts</id>
<phase>verify</phase>
<phase>verify</phase>
<goals>
<goals>
<goal>sign</goal>
<goal>sign</goal>
</goals>
</goals>
<configuration>
<configuration>
<gpgArguments>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
<arg>loopback</arg>
</gpgArguments>
</gpgArguments>
</configuration>
</configuration>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
</profile>
</profile>
</profiles>
</profiles>
<organization>
<organization>
<name>Stream Pi</name>
<name>Stream Pi</name>
<url>https://www.stream-pi.com</url>
<url>https://www.stream-pi.com</url>
</organization>
</organization>
<issueManagement>
<issueManagement>
<system>GitHub</system>
<system>GitHub</system>
<url>https://github.com/Stream-Pi/util/issues</url>
<url>https://github.com/Stream-Pi/util/issues</url>
</issueManagement>
</issueManagement>
<licenses>
<licenses>
<license>
<license>
<name>GPL-3.0 License</name>
<name>GPL-3.0 License</name>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
<distribution>repo</distribution>
<distribution>repo</distribution>
</license>
</license>
</licenses>
</licenses>
<developers>
<developers>
<developer>
<developer>
<name>Debayan Sutradhar</name>
<name>Debayan Sutradhar</name>
<email>debayansutradhar3@gmail.com</email>
<email>debayansutradhar3@gmail.com</email>
<organization>Stream-Pi</organization>
<organization>Stream-Pi</organization>
<organizationUrl>https://www.stream-pi.com</organizationUrl>
<organizationUrl>https://www.stream-pi.com</organizationUrl>
</developer>
</developer>
<developer>
<developer>
<name>Abhinay Agarwal</name>
<name>Abhinay Agarwal</name>
<email>abhinay.agarwal@gluonhq.com</email>
<email>abhinay.agarwal@gluonhq.com</email>
<organization>Gluon</organization>
<organization>Gluon</organization>
<organizationUrl>https://www.gluonhq.com</organizationUrl>
<organizationUrl>https://www.gluonhq.com</organizationUrl>
</developer>
</developer>
</developers>
</developers>
<scm>
<scm>
<url>https://github.com/stream-pi/util</url>
<url>https://github.com/stream-pi/util</url>
<connection>scm:git:git://github.com/stream-pi/util.git</connection>
<connection>scm:git:git://github.com/stream-pi/util.git</connection>
<developerConnection>scm:git:ssh://git@github.com:stream-pi/util.git</developerConnection>
<developerConnection>scm:git:ssh://git@github.com:stream-pi/util.git</developerConnection>
</scm>
</scm>
<distributionManagement>
<distributionManagement>
<snapshotRepository>
<snapshotRepository>
<id>ossrh</id>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</snapshotRepository>
<repository>
<repository>
<id>ossrh</id>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</repository>
</distributionManagement>
</distributionManagement>
</project>
</project>
package com.stream_pi.util.checkforupdates;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.platform.PlatformType;
import com.stream_pi.util.version.Version;
import javafx.application.HostServices;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
public class CheckForUpdates extends Task<Void>
{
private final Button checkForUpdatesButton;
private final HostServices hostServices;
private final PlatformType platformType;
private final Version currentVersion;
public CheckForUpdates(Button checkForUpdatesButton, HostServices hostServices,
PlatformType platformType, Version currentVersion)
{
this.checkForUpdatesButton = checkForUpdatesButton;
this.hostServices = hostServices;
this.platformType = platformType;
this.currentVersion = currentVersion;
new Thread(this).start();
}
@Override
protected Void call()
{
try
{
Platform.runLater(()->checkForUpdatesButton.setDisable(true));
String url_pre = "https://stream-pi.com/API/get_latest.php?TYPE=";
if(platformType == PlatformType.SERVER)
{
url_pre+="SERVER";
}
else
{
url_pre+="CLIENT";
}
String content = readUrl(url_pre);
JsonObject jsonObject = JsonParser.parseString(content).getAsJsonObject();
String latestVersionRaw = jsonObject.get("Version").getAsString();
String releasePage = jsonObject.get("Release Page").getAsString();
Version latestVersion = new Version(latestVersionRaw);
if(latestVersion.isBiggerThan(currentVersion))
{
VBox vBox = new VBox();
Hyperlink urlLabel = new Hyperlink(releasePage);
urlLabel.setOnAction(event->hostServices.showDocument(releasePage));
Label label = new Label(
"New Version "+latestVersionRaw+" Available.\n" +
"Current Version "+currentVersion.getText()+".\n"+
"Changelog and install instructions are included in the release page.\n" +
"It is recommended to update to ensure maximum stability and least bugs.");
label.setWrapText(true);
vBox.setSpacing(5);
vBox.getChildren().addAll(
urlLabel,
label
);
new StreamPiAlert("New Update Available!", StreamPiAlertType.INFORMATION, vBox).show();
}
else
{
new StreamPiAlert("Up to Date", "System is up to date. ("+currentVersion.getText()+")", StreamPiAlertType.INFORMATION).show();;
}
}
catch (Exception e)
{
e.printStackTrace();
new StreamPiAlert("Uh Oh", "Update Check Failed. \n\nMessage : "+e.getMessage(), StreamPiAlertType.ERROR).show();;
}
finally
{
Platform.runLater(()->checkForUpdatesButton.setDisable(false));
}
return null;
}
private String readUrl(String urlString) throws Exception
{
URL url = new URL(urlString);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuilder buffer = new StringBuilder();
int read;
char[] chars = new char[1024];
while ((read = reader.read(chars)) != -1)
buffer.append(chars, 0, read);
reader.close();
return buffer.toString();
}
}
/*
/*
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
This program is free software: you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
Originally Written by : Debayan Sutradhar (rnayabed)
Originally Written by : Debayan Sutradhar (rnayabed)
*/
*/
package com.stream_pi.util.platform;
package com.stream_pi.util.platform;
public enum Platform {
public enum Platform {
WINDOWS("Windows"),
WINDOWS("Windows"),
LINUX("Linux"),
LINUX("Linux"),
MAC("MacOS"),
MAC("MacOS"),
ANDROID("Android"),
ANDROID("Android"),
IOS("iOS"),
LINUX_RPI("Raspberry Pi"),
UNKNOWN("Unknown");
UNKNOWN("Unknown");
final private String UIName;
final private String UIName;
Platform(String UIName)
Platform(String UIName)
{
{
this.UIName = UIName;
this.UIName = UIName;
}
}
public String getUIName()
public String getUIName()
{
{
return UIName;
return UIName;
}
}
}
}
package com.stream_pi.util.platform;
public enum PlatformType {
SERVER, CLIENT
}
/*
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Originally Written by : Debayan Sutradhar (rnayabed)
*/
package com.stream_pi.util.startatboot;
public enum SoftwareType {
SERVER, CLIENT
}
/*
/*
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
This program is free software: you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
Originally Written by : Debayan Sutradhar (rnayabed)
Originally Written by : Debayan Sutradhar (rnayabed)
*/
*/
package com.stream_pi.util.startatboot;
package com.stream_pi.util.startatboot;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.platform.PlatformType;
import java.io.BufferedWriter;
import java.io.BufferedWriter;
import java.io.File;
import java.io.File;
import java.io.FileWriter;
import java.io.FileWriter;
public class StartAtBoot {
public class StartAtBoot {
SoftwareType softwareType;
PlatformType softwareType;
Platform platform;
Platform platform;
public StartAtBoot(SoftwareType softwareType, Platform platform)
public StartAtBoot(PlatformType softwareType, Platform platform)
{
{
this.softwareType = softwareType;
this.softwareType = softwareType;
this.platform = platform;
this.platform = platform;
}
}
public void create(File runnerFile) throws MinorException
public void create(File runnerFile) throws MinorException
{
{
if(platform == Platform.WINDOWS)
if(platform == Platform.WINDOWS)
createStarterForWindows(runnerFile);
createStarterForWindows(runnerFile);
else if(platform == Platform.LINUX || platform == Platform.LINUX_RPI)
else if(platform == Platform.LINUX)
createStarterForLinux(runnerFile, true);
createStarterForLinux(runnerFile, true);
else if(platform == Platform.MAC)
else if(platform == Platform.MAC)
createStarterForMac(runnerFile);
createStarterForMac(runnerFile);
else if(platform == Platform.UNKNOWN)
else if(platform == Platform.UNKNOWN)
unknownPlatformException();
unknownPlatformException();
}
}
public void create(File runnerFile, boolean isXMode) throws MinorException
public void create(File runnerFile, boolean isXMode) throws MinorException
{
{
if(platform == Platform.WINDOWS)
if(platform == Platform.WINDOWS)
createStarterForWindows(runnerFile);
createStarterForWindows(runnerFile);
else if(platform == Platform.LINUX || platform == Platform.LINUX_RPI)
else if(platform == Platform.LINUX)
createStarterForLinux(runnerFile, isXMode);
createStarterForLinux(runnerFile, isXMode);
else if(platform == Platform.MAC)
else if(platform == Platform.MAC)
createStarterForMac(runnerFile);
createStarterForMac(runnerFile);
else if(platform == Platform.UNKNOWN)
else if(platform == Platform.UNKNOWN)
unknownPlatformException();
unknownPlatformException();
}
}
public boolean delete() throws MinorException {
public boolean delete() throws MinorException {
if(platform == Platform.WINDOWS)
if(platform == Platform.WINDOWS)
return deleteStarterForWindows();
return deleteStarterForWindows();
else if (platform == Platform.LINUX || platform == Platform.LINUX_RPI)
else if (platform == Platform.LINUX)
return deleteStarterForLinux();
return deleteStarterForLinux();
else if(platform == Platform.MAC)
else if(platform == Platform.MAC)
deleteStarterForMac();
deleteStarterForMac();
else if(platform == Platform.UNKNOWN)
else if(platform == Platform.UNKNOWN)
unknownPlatformException();
unknownPlatformException();
return false;
return false;
}
}
private void createStarterForLinux(File runnerFile, boolean isXMode) throws MinorException
private void createStarterForLinux(File runnerFile, boolean isXMode) throws MinorException
{
{
try
try
{
{
String sysDDirectoryPath = System.getProperty("user.home")+"/.local/share/systemd/user/";
String sysDDirectoryPath = System.getProperty("user.home")+"/.local/share/systemd/user/";
File sysDDirectoryFile = new File(sysDDirectoryPath);
File sysDDirectoryFile = new File(sysDDirectoryPath);
if(!sysDDirectoryFile.exists())
if(!sysDDirectoryFile.exists())
sysDDirectoryFile.mkdirs();
sysDDirectoryFile.mkdirs();
File sysDServiceFile = new File(sysDDirectoryPath+"stream-pi-"+ softwareType+".service");
File sysDServiceFile = new File(sysDDirectoryPath+"stream-pi-"+ softwareType+".service");
FileWriter fw = new FileWriter(sysDServiceFile);
FileWriter fw = new FileWriter(sysDServiceFile);
BufferedWriter bw = new BufferedWriter(fw);
BufferedWriter bw = new BufferedWriter(fw);
if(isXMode)
if(isXMode)
{
{
bw.write("[Unit]\n" +
bw.write("[Unit]\n" +
"Description=Stream-Pi "+softwareType+"\n" +
"Description=Stream-Pi "+softwareType+"\n" +
"[Service]\n" +
"[Service]\n" +
"Type=simple\n" +
"Type=simple\n" +
"Environment=\"DISPLAY=:0\"\n" +
"Environment=\"DISPLAY=:0\"\n" +
"WorkingDirectory="+runnerFile.getAbsoluteFile().getParent()+"\n" +
"WorkingDirectory="+runnerFile.getAbsoluteFile().getParent()+"\n" +
"ExecStart="+runnerFile.getAbsoluteFile().getParent()+"/"+runnerFile.getName()+"\n" +
"ExecStart="+runnerFile.getAbsoluteFile().getParent()+"/"+runnerFile.getName()+"\n" +
"[Install]\n" +
"[Install]\n" +
"WantedBy=default.target\n");
"WantedBy=default.target\n");
}
}
else
else
{
{
bw.write("[Unit]\n" +
bw.write("[Unit]\n" +
"Description=Stream-Pi "+softwareType+"\n" +
"Description=Stream-Pi "+softwareType+"\n" +
"[Service]\n" +
"[Service]\n" +
"Type=oneshot\n" +
"Type=oneshot\n" +
"WorkingDirectory="+runnerFile.getAbsoluteFile().getParent()+"\n" +
"WorkingDirectory="+runnerFile.getAbsoluteFile().getParent()+"\n" +
"ExecStart="+runnerFile.getAbsoluteFile().getParent()+"/"+runnerFile.getName()+"\n" +
"ExecStart="+runnerFile.getAbsoluteFile().getParent()+"/"+runnerFile.getName()+"\n" +
"[Install]\n" +
"[Install]\n" +
"WantedBy=default.target\n");
"WantedBy=default.target\n");
}
}
bw.close();
bw.close();
Runtime.getRuntime().exec("systemctl --user daemon-reload");
Runtime.getRuntime().exec("systemctl --user daemon-reload");
Runtime.getRuntime().exec("systemctl --user enable stream-pi-"+softwareType+".service");
Runtime.getRuntime().exec("systemctl --user enable stream-pi-"+softwareType+".service");
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new MinorException("Unable to set start at boot",e.getMessage());
throw new MinorException("Unable to set start at boot",e.getMessage());
}
}
}
}
private boolean deleteStarterForLinux() throws MinorException
private boolean deleteStarterForLinux() throws MinorException
{
{
try
try
{
{
boolean f1 = new File(System.getProperty("user.home")+"/.local/share/systemd/user/stream-pi-"+
boolean f1 = new File(System.getProperty("user.home")+"/.local/share/systemd/user/stream-pi-"+
softwareType+".service").delete();
softwareType+".service").delete();
Runtime.getRuntime().exec("systemctl --user daemon-reload");
Runtime.getRuntime().exec("systemctl --user daemon-reload");
return f1;
return f1;
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new MinorException("Unable to unset start at boot",e.getMessage());
throw new MinorException("Unable to unset start at boot",e.getMessage());
}
}
}
}
private void createStarterForWindows(File runnerFile) throws MinorException
private void createStarterForWindows(File runnerFile) throws MinorException
{
{
File initFile = new File(System.getenv("APPDATA")+"/Microsoft/Windows/Start Menu/Programs/Startup/streampi_starter_"+ softwareType +".bat");
File initFile = new File(System.getenv("APPDATA")+"/Microsoft/Windows/Start Menu/Programs/Startup/streampi_starter_"+ softwareType +".bat");
try
try
{
{
FileWriter fw = new FileWriter(initFile);
FileWriter fw = new FileWriter(initFile);
BufferedWriter bw = new BufferedWriter(fw);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("cd "+runnerFile.getAbsoluteFile().getParent()+"\n" +
bw.write("cd "+runnerFile.getAbsoluteFile().getParent()+"\n" +
runnerFile.getName());
runnerFile.getName());
bw.close();
bw.close();
}
}
catch (Exception e)
catch (Exception e)
{
{
throw new MinorException(e.getMessage());
throw new MinorException(e.getMessage());
}
}
}
}
private boolean deleteStarterForWindows()
private boolean deleteStarterForWindows()
{
{
return new File(System.getenv("APPDATA")+"/Microsoft/Windows/Start Menu/Programs/Startup/streampi_starter_"+ softwareType +".bat").delete();
return new File(System.getenv("APPDATA")+"/Microsoft/Windows/Start Menu/Programs/Startup/streampi_starter_"+ softwareType +".bat").delete();
}
}
private void createStarterForMac(File runnerFile) throws MinorException
private void createStarterForMac(File runnerFile) throws MinorException
{
{
throw new MinorException("Mac Starter feature is not implemented yet.");
throw new MinorException("Mac Starter feature is not implemented yet.");
}
}
private void deleteStarterForMac() throws MinorException
private void deleteStarterForMac() throws MinorException
{
{
throw new MinorException("Mac Starter feature is not implemented yet.");
throw new MinorException("Mac Starter feature is not implemented yet.");
}
}
private void unknownPlatformException() throws MinorException
private void unknownPlatformException() throws MinorException
{
{
throw new MinorException("Cannot implemented starter feature. Unknown platform.");
throw new MinorException("Cannot implemented starter feature. Unknown platform.");
}
}
}
}
/*
/*
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
This program is free software: you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
Originally Written by : Debayan Sutradhar (rnayabed)
Originally Written by : Debayan Sutradhar (rnayabed)
*/
*/
module com.stream_pi.util
module com.stream_pi.util
{
{
requires transitive org.kordamp.ikonli.javafx;
requires transitive org.kordamp.ikonli.javafx;
requires transitive org.kordamp.ikonli.fontawesome5;
requires transitive org.kordamp.ikonli.fontawesome5;
requires transitive javafx.base;
requires transitive javafx.base;
requires transitive java.logging;
requires transitive java.logging;
requires transitive javafx.controls;
requires transitive javafx.controls;
requires transitive java.xml;
requires transitive java.xml;
requires com.google.gson;
exports com.stream_pi.util.version;
exports com.stream_pi.util.version;
exports com.stream_pi.util.exception;
exports com.stream_pi.util.exception;
exports com.stream_pi.util.platform;
exports com.stream_pi.util.platform;
exports com.stream_pi.util.uihelper;
exports com.stream_pi.util.uihelper;
exports com.stream_pi.util.startatboot;
exports com.stream_pi.util.startatboot;
exports com.stream_pi.util.alert;
exports com.stream_pi.util.alert;
exports com.stream_pi.util.checkforupdates;
exports com.stream_pi.util.combobox;
exports com.stream_pi.util.combobox;
exports com.stream_pi.util.xmlconfighelper;
exports com.stream_pi.util.xmlconfighelper;
exports com.stream_pi.util.loggerhelper;
exports com.stream_pi.util.loggerhelper;
exports com.stream_pi.util.iohelper;
exports com.stream_pi.util.iohelper;
exports com.stream_pi.util.comms;
exports com.stream_pi.util.comms;
}
}