Allow user to set the computer name

This commit is contained in:
Laurent Clouet
2017-05-08 01:35:08 +02:00
parent cb03b58dbc
commit c6f48661f0
5 changed files with 54 additions and 15 deletions

View File

@@ -24,6 +24,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.LinkedList;
@@ -58,11 +60,13 @@ public class Configuration {
private boolean autoSignIn;
private String UIType;
private int tileSize;
private String hostname;
public Configuration(File cache_dir_, String login_, String password_) {
this.login = login_;
this.password = password_;
this.proxy = null;
this.hostname = this.getDefaultHostname();
this.static_exeDirName = "exe";
this.maxUploadingJob = 1;
this.nbCores = -1; // ie not set
@@ -83,6 +87,7 @@ public class Configuration {
this.tileSize = -1; // ie not set
}
public String toString() {
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
}
@@ -268,6 +273,23 @@ public class Configuration {
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() {
this.cleanDirectory(this.workingDirectory);
this.cleanDirectory(this.storageDirectory);