Allow user to set the computer name
This commit is contained in:
@@ -24,6 +24,8 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -58,11 +60,13 @@ public class Configuration {
|
|||||||
private boolean autoSignIn;
|
private boolean autoSignIn;
|
||||||
private String UIType;
|
private String UIType;
|
||||||
private int tileSize;
|
private int tileSize;
|
||||||
|
private String hostname;
|
||||||
|
|
||||||
public Configuration(File cache_dir_, String login_, String password_) {
|
public Configuration(File cache_dir_, String login_, String password_) {
|
||||||
this.login = login_;
|
this.login = login_;
|
||||||
this.password = password_;
|
this.password = password_;
|
||||||
this.proxy = null;
|
this.proxy = null;
|
||||||
|
this.hostname = this.getDefaultHostname();
|
||||||
this.static_exeDirName = "exe";
|
this.static_exeDirName = "exe";
|
||||||
this.maxUploadingJob = 1;
|
this.maxUploadingJob = 1;
|
||||||
this.nbCores = -1; // ie not set
|
this.nbCores = -1; // ie not set
|
||||||
@@ -83,6 +87,7 @@ public class Configuration {
|
|||||||
this.tileSize = -1; // ie not set
|
this.tileSize = -1; // ie not set
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
|
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
@@ -268,6 +273,23 @@ public class Configuration {
|
|||||||
return this.tileSize;
|
return this.tileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHostname(String hostname_) {
|
||||||
|
this.hostname = hostname_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHostname() {
|
||||||
|
return this.hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultHostname() {
|
||||||
|
try {
|
||||||
|
return InetAddress.getLocalHost().getHostName();
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void cleanWorkingDirectory() {
|
public void cleanWorkingDirectory() {
|
||||||
this.cleanDirectory(this.workingDirectory);
|
this.cleanDirectory(this.workingDirectory);
|
||||||
this.cleanDirectory(this.storageDirectory);
|
this.cleanDirectory(this.storageDirectory);
|
||||||
|
|||||||
@@ -34,12 +34,10 @@ import java.io.StringWriter;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.NoRouteToHostException;
|
import java.net.NoRouteToHostException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
@@ -184,14 +182,6 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
|||||||
OS os = OS.getOS();
|
OS os = OS.getOS();
|
||||||
HttpURLConnection connection = null;
|
HttpURLConnection connection = null;
|
||||||
try {
|
try {
|
||||||
String hostname;
|
|
||||||
try {
|
|
||||||
hostname = InetAddress.getLocalHost().getHostName();
|
|
||||||
}
|
|
||||||
catch (UnknownHostException e) {
|
|
||||||
this.log.error("Server::getConfiguration failed to get hostname (exception: " + e + ")");
|
|
||||||
hostname = "";
|
|
||||||
}
|
|
||||||
String url_contents = String.format("%s%s?login=%s&password=%s&cpu_family=%s&cpu_model=%s&cpu_model_name=%s&cpu_cores=%s&os=%s&ram=%s&bits=%s&version=%s&hostname=%s&extras=%s",
|
String url_contents = String.format("%s%s?login=%s&password=%s&cpu_family=%s&cpu_model=%s&cpu_model_name=%s&cpu_cores=%s&os=%s&ram=%s&bits=%s&version=%s&hostname=%s&extras=%s",
|
||||||
this.base_url,
|
this.base_url,
|
||||||
"/server/config.php",
|
"/server/config.php",
|
||||||
@@ -205,7 +195,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
|||||||
os.getMemory(),
|
os.getMemory(),
|
||||||
URLEncoder.encode(os.getCPU().arch(), "UTF-8"),
|
URLEncoder.encode(os.getCPU().arch(), "UTF-8"),
|
||||||
this.user_config.getJarVersion(),
|
this.user_config.getJarVersion(),
|
||||||
URLEncoder.encode(hostname, "UTF-8"),
|
URLEncoder.encode(this.user_config.getHostname(), "UTF-8"),
|
||||||
this.user_config.getExtras());
|
this.user_config.getExtras());
|
||||||
this.log.debug("Server::getConfiguration url " + url_contents);
|
this.log.debug("Server::getConfiguration url " + url_contents);
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public class SettingsLoader {
|
|||||||
private String login;
|
private String login;
|
||||||
private String password;
|
private String password;
|
||||||
private String proxy;
|
private String proxy;
|
||||||
|
private String hostname;
|
||||||
private String computeMethod;
|
private String computeMethod;
|
||||||
private String gpu;
|
private String gpu;
|
||||||
private String cores;
|
private String cores;
|
||||||
@@ -62,11 +63,12 @@ public class SettingsLoader {
|
|||||||
path = path_;
|
path = path_;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsLoader(String login_, String password_, String proxy_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
public SettingsLoader(String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||||
path = getDefaultFilePath();
|
path = getDefaultFilePath();
|
||||||
login = login_;
|
login = login_;
|
||||||
password = password_;
|
password = password_;
|
||||||
proxy = proxy_;
|
proxy = proxy_;
|
||||||
|
hostname = hostname_;
|
||||||
cacheDir = cacheDir_;
|
cacheDir = cacheDir_;
|
||||||
autoSignIn = String.valueOf(autoSignIn_);
|
autoSignIn = String.valueOf(autoSignIn_);
|
||||||
ui = ui_;
|
ui = ui_;
|
||||||
@@ -145,6 +147,10 @@ public class SettingsLoader {
|
|||||||
prop.setProperty("proxy", proxy);
|
prop.setProperty("proxy", proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hostname != null) {
|
||||||
|
prop.setProperty("hostname", hostname);
|
||||||
|
}
|
||||||
|
|
||||||
if (autoSignIn != null) {
|
if (autoSignIn != null) {
|
||||||
prop.setProperty("auto-signin", autoSignIn);
|
prop.setProperty("auto-signin", autoSignIn);
|
||||||
}
|
}
|
||||||
@@ -193,6 +199,7 @@ public class SettingsLoader {
|
|||||||
this.login = null;
|
this.login = null;
|
||||||
this.password = null;
|
this.password = null;
|
||||||
this.proxy = null;
|
this.proxy = null;
|
||||||
|
this.hostname = null;
|
||||||
this.computeMethod = null;
|
this.computeMethod = null;
|
||||||
this.gpu = null;
|
this.gpu = null;
|
||||||
this.cacheDir = null;
|
this.cacheDir = null;
|
||||||
@@ -249,6 +256,10 @@ public class SettingsLoader {
|
|||||||
this.proxy = prop.getProperty("proxy");
|
this.proxy = prop.getProperty("proxy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prop.containsKey("hostname")) {
|
||||||
|
this.hostname = prop.getProperty("hostname");
|
||||||
|
}
|
||||||
|
|
||||||
if (prop.containsKey("auto-signin")) {
|
if (prop.containsKey("auto-signin")) {
|
||||||
this.autoSignIn = prop.getProperty("auto-signin");
|
this.autoSignIn = prop.getProperty("auto-signin");
|
||||||
}
|
}
|
||||||
@@ -302,6 +313,10 @@ public class SettingsLoader {
|
|||||||
config.setProxy(proxy);
|
config.setProxy(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((config.getHostname() == null || config.getHostname().isEmpty() || config.getHostname().equals(config.getDefaultHostname())) && hostname != null) {
|
||||||
|
config.setHostname(hostname);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.getPriority() == 19) { // 19 is default value
|
if (config.getPriority() == 19) { // 19 is default value
|
||||||
config.setUsePriority(priority);
|
config.setUsePriority(priority);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class GuiSwing extends JFrame implements Gui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTitle("SheepIt Render Farm");
|
setTitle("SheepIt Render Farm");
|
||||||
setSize(520, 660);
|
setSize(520, 680);
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class Settings implements Activity {
|
|||||||
private JSpinner renderTime;
|
private JSpinner renderTime;
|
||||||
private JSlider priority;
|
private JSlider priority;
|
||||||
private JTextField proxy;
|
private JTextField proxy;
|
||||||
|
private JTextField hostname;
|
||||||
|
|
||||||
private JCheckBox saveFile;
|
private JCheckBox saveFile;
|
||||||
private JCheckBox autoSignIn;
|
private JCheckBox autoSignIn;
|
||||||
@@ -307,7 +308,7 @@ public class Settings implements Activity {
|
|||||||
parent.getContentPane().add(compute_devices_panel, constraints);
|
parent.getContentPane().add(compute_devices_panel, constraints);
|
||||||
|
|
||||||
// other
|
// other
|
||||||
JPanel advanced_panel = new JPanel(new GridLayout(4, 2));
|
JPanel advanced_panel = new JPanel(new GridLayout(5, 2));
|
||||||
advanced_panel.setBorder(BorderFactory.createTitledBorder("Advanced options"));
|
advanced_panel.setBorder(BorderFactory.createTitledBorder("Advanced options"));
|
||||||
|
|
||||||
JLabel proxyLabel = new JLabel("Proxy:");
|
JLabel proxyLabel = new JLabel("Proxy:");
|
||||||
@@ -320,6 +321,12 @@ public class Settings implements Activity {
|
|||||||
advanced_panel.add(proxyLabel);
|
advanced_panel.add(proxyLabel);
|
||||||
advanced_panel.add(proxy);
|
advanced_panel.add(proxy);
|
||||||
|
|
||||||
|
JLabel hostnameLabel = new JLabel("Computer name:");
|
||||||
|
hostname = new JTextField();
|
||||||
|
hostname.setText(parent.getConfiguration().getHostname());
|
||||||
|
|
||||||
|
advanced_panel.add(hostnameLabel);
|
||||||
|
advanced_panel.add(hostname);
|
||||||
|
|
||||||
JLabel renderTimeLabel = new JLabel("Max time per frame (in minute):");
|
JLabel renderTimeLabel = new JLabel("Max time per frame (in minute):");
|
||||||
int val = 0;
|
int val = 0;
|
||||||
@@ -592,8 +599,13 @@ public class Settings implements Activity {
|
|||||||
cachePath = config.getStorageDir().getAbsolutePath();
|
cachePath = config.getStorageDir().getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String hostnameText = null;
|
||||||
|
if (hostname.getText() != null && hostname.getText().equals(parent.getConfiguration().getHostname()) == false) {
|
||||||
|
hostnameText = hostname.getText();
|
||||||
|
}
|
||||||
|
|
||||||
if (saveFile.isSelected()) {
|
if (saveFile.isSelected()) {
|
||||||
new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user