|
|
@ -250,20 +250,28 @@ public class ServerSetting implements SimpleListItem { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the appropriate daemon adapter to which tasks can be executed, in accordance with this server's settings |
|
|
|
* Returns the appropriate daemon adapter to which tasks can be executed, in accordance with this server's settings |
|
|
|
|
|
|
|
* @param connectedToNetwork The name of the (wifi) network we are currently connected to, or null if this could not |
|
|
|
|
|
|
|
* be determined |
|
|
|
* @return An IDaemonAdapter instance of the specific torrent client daemon type |
|
|
|
* @return An IDaemonAdapter instance of the specific torrent client daemon type |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public IDaemonAdapter createServerAdapter() { |
|
|
|
public IDaemonAdapter createServerAdapter(String connectedToNetwork) { |
|
|
|
return type.createAdapter(convertToDaemonSettings()); |
|
|
|
return type.createAdapter(convertToDaemonSettings(connectedToNetwork)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private DaemonSettings convertToDaemonSettings() { |
|
|
|
/** |
|
|
|
// Convert local server settings into an old-style DaemonSetting object
|
|
|
|
* Converts local server settings into an old-style {@link DaemonSettings} object. |
|
|
|
// The local integer key is converted to the idString string
|
|
|
|
* @param connectedToNetwork The name of the (wifi) network we are currently connected to, or null if this could not |
|
|
|
// TODO: Add localaddress and localnetwork to DaemonSettings, or solve properly rework the Connect library
|
|
|
|
* be determined |
|
|
|
// handling of settings
|
|
|
|
* @return A {@link DaemonSettings} object to execute server commands against |
|
|
|
return new DaemonSettings(name, type, address, port, ssl, sslTrustAll, sslTrustKey, |
|
|
|
*/ |
|
|
|
folder, useAuthentication, username, password, extraPass, os, downloadDir, ftpUrl, ftpPassword, |
|
|
|
private DaemonSettings convertToDaemonSettings(String connectedToNetwork) { |
|
|
|
timeout, alarmOnFinishedDownload, alarmOnNewTorrent, Integer.toString(key), isAutoGenerated); |
|
|
|
// The local integer key is converted to the idString string.
|
|
|
|
|
|
|
|
// The host name address used is dependent on the network that we are currently connected to (to allow a
|
|
|
|
|
|
|
|
// distinct connection IP or host name when connected to a local network).
|
|
|
|
|
|
|
|
return new DaemonSettings(name, type, |
|
|
|
|
|
|
|
connectedToNetwork != null && connectedToNetwork.equals(localNetwork) ? localAddress : address, port, |
|
|
|
|
|
|
|
ssl, sslTrustAll, sslTrustKey, folder, useAuthentication, username, password, extraPass, os, |
|
|
|
|
|
|
|
downloadDir, ftpUrl, ftpPassword, timeout, alarmOnFinishedDownload, alarmOnNewTorrent, |
|
|
|
|
|
|
|
Integer.toString(key), isAutoGenerated); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|