Browse Source

Fixed #40 by adding a new local port option.

pull/82/head
Eric Kok 11 years ago
parent
commit
8a0e638698
  1. 1
      core/res/values/strings.xml
  2. 13
      core/res/xml/pref_server.xml
  3. 53
      core/src/org/transdroid/core/app/settings/ApplicationSettings.java
  4. 26
      core/src/org/transdroid/core/app/settings/ServerSetting.java
  5. 3
      core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java

1
core/res/values/strings.xml

@ -233,6 +233,7 @@ @@ -233,6 +233,7 @@
<string name="pref_advanced">Advanced settings</string>
<string name="pref_localaddress">Local IP or host</string>
<string name="pref_localaddress_info">When connected to the specified local network</string>
<string name="pref_localport">Local port number</string>
<string name="pref_localnetwork">Local network</string>
<string name="pref_localnetwork_info">The server\'s local network SSID</string>
<string name="pref_folder">Folder</string>

13
core/res/xml/pref_server.xml

@ -49,16 +49,21 @@ @@ -49,16 +49,21 @@
android:key="server_port"
android:title="@string/pref_port"
android:inputType="numberSigned" />
<EditTextPreference
android:key="server_localnetwork"
android:title="@string/pref_localnetwork"
android:summary="@string/pref_localnetwork_info"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="server_localaddress"
android:title="@string/pref_localaddress"
android:summary="@string/pref_localaddress_info"
android:inputType="textUri" />
<EditTextPreference
android:key="server_localnetwork"
android:title="@string/pref_localnetwork"
android:summary="@string/pref_localnetwork_info"
android:inputType="textNoSuggestions" />
android:key="server_localport"
android:title="@string/pref_localport"
android:summary="@string/pref_localaddress_info"
android:inputType="numberSigned" />
<CheckBoxPreference
android:key="server_disableauth"
android:title="@string/pref_disableauth"

53
core/src/org/transdroid/core/app/settings/ApplicationSettings.java

@ -96,19 +96,34 @@ public class ApplicationSettings { @@ -96,19 +96,34 @@ public class ApplicationSettings {
String port = prefs.getString("server_port_" + order, "");
if (port.equals(""))
port = Integer.toString(Daemon.getDefaultPortNumber(type, ssl));
return new ServerSetting(order, prefs.getString("server_name_" + order, null), type, prefs.getString(
"server_address_" + order, null), prefs.getString("server_localaddress_" + order, null),
prefs.getString("server_localnetwork_" + order, null), Integer.parseInt(port), ssl, prefs.getBoolean(
"server_ssltrustall_" + order, false), prefs.getString("server_ssltrustkey_" + order, null),
String localPort = prefs.getString("server_localport_" + order, "");
if (localPort.equals(""))
localPort = port; // Default to the normal (non-local) port
return new ServerSetting(order,
prefs.getString("server_name_" + order, null),
type,
prefs.getString("server_address_" + order, null),
prefs.getString("server_localaddress_" + order, null),
Integer.parseInt(localPort),
prefs.getString("server_localnetwork_" + order, null),
Integer.parseInt(port),
ssl,
prefs.getBoolean("server_ssltrustall_" + order, false),
prefs.getString("server_ssltrustkey_" + order, null),
prefs.getString("server_folder_" + order, null),
!prefs.getBoolean("server_disableauth_" + order, false), prefs.getString("server_user_" + order, null),
prefs.getString("server_pass_" + order, null), prefs.getString("server_extrapass_" + order, null),
OS.fromCode(prefs.getString("server_os_" + order, "type_linux")), prefs.getString("server_downloaddir_"
+ order, null), prefs.getString("server_ftpurl_" + order, null), prefs.getString(
"server_ftppass_" + order, null), Integer.parseInt(prefs.getString("server_timeout_" + order,
"8")), prefs.getBoolean("server_alarmfinished_" + order, true), prefs.getBoolean(
"server_alarmnew_" + order, false), false);
!prefs.getBoolean("server_disableauth_" + order, false),
prefs.getString("server_user_" + order, null),
prefs.getString("server_pass_" + order, null),
prefs.getString("server_extrapass_" + order, null),
OS.fromCode(prefs.getString("server_os_" + order, "type_linux")),
prefs.getString("server_downloaddir_" + order, null),
prefs.getString("server_ftpurl_" + order, null),
prefs.getString("server_ftppass_" + order, null),
Integer.parseInt(prefs.getString("server_timeout_" + order, "8")),
prefs.getBoolean("server_alarmfinished_" + order, true),
prefs.getBoolean("server_alarmnew_" + order, false),
false);
// @formatter:on
}
@ -251,8 +266,10 @@ public class ApplicationSettings { @@ -251,8 +266,10 @@ public class ApplicationSettings {
*/
public WebsearchSetting getWebsearchSetting(int order) {
// @formatter:off
return new WebsearchSetting(order, prefs.getString("websearch_name_" + order, null), prefs.getString(
"websearch_baseurl_" + order, null), prefs.getString("websearch_cookies_" + order, null));
return new WebsearchSetting(order,
prefs.getString("websearch_name_" + order, null),
prefs.getString("websearch_baseurl_" + order, null),
prefs.getString("websearch_cookies_" + order, null));
// @formatter:on
}
@ -313,9 +330,11 @@ public class ApplicationSettings { @@ -313,9 +330,11 @@ public class ApplicationSettings {
public RssfeedSetting getRssfeedSetting(int order) {
// @formatter:off
long lastViewed = prefs.getLong("rssfeed_lastviewed_" + order, -1);
return new RssfeedSetting(order, prefs.getString("rssfeed_name_" + order, null), prefs.getString("rssfeed_url_"
+ order, null), prefs.getBoolean("rssfeed_reqauth_" + order, false), lastViewed == -1L ? null
: new Date(lastViewed));
return new RssfeedSetting(order,
prefs.getString("rssfeed_name_" + order, null),
prefs.getString("rssfeed_url_" + order, null),
prefs.getBoolean("rssfeed_reqauth_" + order, false),
lastViewed == -1L ? null : new Date(lastViewed));
// @formatter:on
}

26
core/src/org/transdroid/core/app/settings/ServerSetting.java

@ -40,6 +40,7 @@ public class ServerSetting implements SimpleListItem { @@ -40,6 +40,7 @@ public class ServerSetting implements SimpleListItem {
private final Daemon type;
private final String address;
private final String localAddress;
private final int localPort;
private final String localNetwork;
private final int port;
private final String folder;
@ -65,6 +66,7 @@ public class ServerSetting implements SimpleListItem { @@ -65,6 +66,7 @@ public class ServerSetting implements SimpleListItem {
* @param type The server daemon type
* @param address The server domain name or IP address
* @param localAddress The server domain or IP address when connected to the server's local network
* @param localPort The port on which the server is running in the server's local network
* @param localNetwork The server's local network SSID
* @param port The port on which the server daemon is running
* @param sslTrustKey The specific key that will be accepted.
@ -78,16 +80,17 @@ public class ServerSetting implements SimpleListItem { @@ -78,16 +80,17 @@ public class ServerSetting implements SimpleListItem {
* @param timeout The number of seconds to wait before timing out a connection attempt
* @param isAutoGenerated Whether this setting was generated rather than manually inputed by the user
*/
public ServerSetting(int key, String name, Daemon type, String address, String localAddress, String localNetwork,
int port, boolean ssl, boolean sslTrustAll, String sslTrustKey, String folder, boolean useAuthentication,
String username, String password, String extraPass, OS os, String downloadDir, String ftpUrl,
String ftpPassword, int timeout, boolean alarmOnFinishedDownload, boolean alarmOnNewTorrent,
public ServerSetting(int key, String name, Daemon type, String address, String localAddress, int localPort,
String localNetwork, int port, boolean ssl, boolean sslTrustAll, String sslTrustKey, String folder,
boolean useAuthentication, String username, String password, String extraPass, OS os, String downloadDir,
String ftpUrl, String ftpPassword, int timeout, boolean alarmOnFinishedDownload, boolean alarmOnNewTorrent,
boolean isAutoGenerated) {
this.key = key;
this.name = name;
this.type = type;
this.address = address;
this.localAddress = localAddress;
this.localPort = localPort;
this.localNetwork = localNetwork;
this.port = port;
this.ssl = ssl;
@ -131,6 +134,10 @@ public class ServerSetting implements SimpleListItem { @@ -131,6 +134,10 @@ public class ServerSetting implements SimpleListItem {
return localAddress;
}
public int getLocalPort() {
return localPort;
}
public String getLocalNetwork() {
return localNetwork;
}
@ -254,7 +261,7 @@ public class ServerSetting implements SimpleListItem { @@ -254,7 +261,7 @@ public class ServerSetting implements SimpleListItem {
* 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
* @param context
* @param context
* @return An IDaemonAdapter instance of the specific torrent client daemon type
*/
public IDaemonAdapter createServerAdapter(String connectedToNetwork, Context context) {
@ -276,9 +283,10 @@ public class ServerSetting implements SimpleListItem { @@ -276,9 +283,10 @@ public class ServerSetting implements SimpleListItem {
Log.d(caller, "Creating adapter for " + name + " of type " + type.name() + ": connected to "
+ connectedToNetwork + " and configured local network is " + localNetwork);
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);
connectedToNetwork != null && connectedToNetwork.equals(localNetwork) ? localAddress : address,
connectedToNetwork != null && connectedToNetwork.equals(localNetwork) ? localPort : port, ssl,
sslTrustAll, sslTrustKey, folder, useAuthentication, username, password, extraPass, os, downloadDir,
ftpUrl, ftpPassword, timeout, alarmOnFinishedDownload, alarmOnNewTorrent, Integer.toString(key),
isAutoGenerated);
}
}

3
core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -57,8 +57,9 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -57,8 +57,9 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
initTextPreference("server_user");
initTextPreference("server_pass");
extraPass = initTextPreference("server_extrapass");
initTextPreference("server_localaddress");
initTextPreference("server_localnetwork");
initTextPreference("server_localaddress");
initTextPreference("server_localport");
folder = initTextPreference("server_folder");
initTextPreference("server_timeout", "8");
initBooleanPreference("server_alarmfinished", true);

Loading…
Cancel
Save