- New config for proxying news, separate from proxying update
 - Default logic cleanup
This commit is contained in:
zzz
2013-10-04 20:21:54 +00:00
parent 8a0c3f10f4
commit a5e3bc9b85
6 changed files with 27 additions and 8 deletions

View File

@ -73,7 +73,7 @@ class NewsFetcher extends UpdateRunner {
} }
public void fetchNews() { public void fetchNews() {
boolean shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue(); boolean shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY_NEWS, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY_NEWS);
String proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST); String proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
int proxyPort = ConfigUpdateHandler.proxyPort(_context); int proxyPort = ConfigUpdateHandler.proxyPort(_context);

View File

@ -98,7 +98,7 @@ class PluginUpdateRunner extends UpdateRunner {
} else { } else {
updateStatus("<b>" + _("Downloading plugin from {0}", _xpi2pURL) + "</b>"); updateStatus("<b>" + _("Downloading plugin from {0}", _xpi2pURL) + "</b>");
// use the same settings as for updater // use the same settings as for updater
boolean shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue(); boolean shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
String proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST); String proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
int proxyPort = ConfigUpdateHandler.proxyPort(_context); int proxyPort = ConfigUpdateHandler.proxyPort(_context);
try { try {

View File

@ -149,7 +149,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
int proxyPort; int proxyPort;
boolean isSSL = false; boolean isSSL = false;
if (_method == HTTP) { if (_method == HTTP) {
shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue(); shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST); proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
proxyPort = ConfigUpdateHandler.proxyPort(_context); proxyPort = ConfigUpdateHandler.proxyPort(_context);
} else if (_method == HTTP_CLEARNET) { } else if (_method == HTTP_CLEARNET) {

View File

@ -23,6 +23,7 @@ public class ConfigUpdateHandler extends FormHandler {
private String _proxyHost; private String _proxyHost;
private String _proxyPort; private String _proxyPort;
private boolean _updateThroughProxy; private boolean _updateThroughProxy;
private boolean _newsThroughProxy;
private String _trustedKeys; private String _trustedKeys;
private boolean _updateUnsigned; private boolean _updateUnsigned;
private String _zipURL; private String _zipURL;
@ -37,7 +38,11 @@ public class ConfigUpdateHandler extends FormHandler {
public static final String PROP_UPDATE_POLICY = "router.updatePolicy"; public static final String PROP_UPDATE_POLICY = "router.updatePolicy";
public static final String DEFAULT_UPDATE_POLICY = "download"; public static final String DEFAULT_UPDATE_POLICY = "download";
public static final String PROP_SHOULD_PROXY = "router.updateThroughProxy"; public static final String PROP_SHOULD_PROXY = "router.updateThroughProxy";
public static final String DEFAULT_SHOULD_PROXY = Boolean.TRUE.toString(); public static final boolean DEFAULT_SHOULD_PROXY = true;
/** @since 0.9.9 */
public static final String PROP_SHOULD_PROXY_NEWS = "router.fetchNewsThroughProxy";
/** @since 0.9.9 */
public static final boolean DEFAULT_SHOULD_PROXY_NEWS = true;
public static final String PROP_PROXY_HOST = "router.updateProxyHost"; public static final String PROP_PROXY_HOST = "router.updateProxyHost";
public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
public static final String PROP_PROXY_PORT = "router.updateProxyPort"; public static final String PROP_PROXY_PORT = "router.updateProxyPort";
@ -164,6 +169,8 @@ public class ConfigUpdateHandler extends FormHandler {
Map<String, String> changes = new HashMap(); Map<String, String> changes = new HashMap();
if ( (_newsURL != null) && (_newsURL.length() > 0) ) { if ( (_newsURL != null) && (_newsURL.length() > 0) ) {
if (_newsURL.startsWith("https"))
_newsThroughProxy = false;
String oldURL = ConfigUpdateHelper.getNewsURL(_context); String oldURL = ConfigUpdateHelper.getNewsURL(_context);
if ( (oldURL == null) || (!_newsURL.equals(oldURL)) ) { if ( (oldURL == null) || (!_newsURL.equals(oldURL)) ) {
changes.put(PROP_NEWS_URL, _newsURL); changes.put(PROP_NEWS_URL, _newsURL);
@ -189,8 +196,9 @@ public class ConfigUpdateHandler extends FormHandler {
} }
} }
changes.put(PROP_SHOULD_PROXY, "" + _updateThroughProxy); changes.put(PROP_SHOULD_PROXY, Boolean.toString(_updateThroughProxy));
changes.put(PROP_UPDATE_UNSIGNED, "" + _updateUnsigned); changes.put(PROP_SHOULD_PROXY_NEWS, Boolean.toString(_newsThroughProxy));
changes.put(PROP_UPDATE_UNSIGNED, Boolean.toString(_updateUnsigned));
String oldFreqStr = _context.getProperty(PROP_REFRESH_FREQUENCY, DEFAULT_REFRESH_FREQUENCY); String oldFreqStr = _context.getProperty(PROP_REFRESH_FREQUENCY, DEFAULT_REFRESH_FREQUENCY);
long oldFreq = DEFAULT_REFRESH_FREQ; long oldFreq = DEFAULT_REFRESH_FREQ;
@ -252,4 +260,6 @@ public class ConfigUpdateHandler extends FormHandler {
public void setProxyPort(String port) { _proxyPort = port; } public void setProxyPort(String port) { _proxyPort = port; }
public void setUpdateUnsigned(String foo) { _updateUnsigned = true; } public void setUpdateUnsigned(String foo) { _updateUnsigned = true; }
public void setZipURL(String url) { _zipURL = url; } public void setZipURL(String url) { _zipURL = url; }
/** @since 0.9.9 */
public void setNewsThroughProxy(String foo) { _newsThroughProxy = true; }
} }

View File

@ -73,13 +73,20 @@ public class ConfigUpdateHelper extends HelperBase {
} }
public String getUpdateThroughProxy() { public String getUpdateThroughProxy() {
String proxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY); if (_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY))
if (Boolean.parseBoolean(proxy))
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" checked=\"checked\" >"; return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" checked=\"checked\" >";
else else
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" >"; return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" >";
} }
/** @since 0.9.9 */
public String getNewsThroughProxy() {
if (_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY_NEWS, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY_NEWS))
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"newsThroughProxy\" checked=\"checked\" >";
else
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"newsThroughProxy\" >";
}
public String getUpdateUnsigned() { public String getUpdateUnsigned() {
if (_context.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_UNSIGNED)) if (_context.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_UNSIGNED))
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" checked=\"checked\" >"; return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" checked=\"checked\" >";

View File

@ -48,6 +48,8 @@
<tr><td class="mediumtags" align="right"><b><%=formhandler._("Update policy")%>:</b></td> <tr><td class="mediumtags" align="right"><b><%=formhandler._("Update policy")%>:</b></td>
<td><jsp:getProperty name="updatehelper" property="updatePolicySelectBox" /></td></tr> <td><jsp:getProperty name="updatehelper" property="updatePolicySelectBox" /></td></tr>
<% } // if canInstall %> <% } // if canInstall %>
<tr><td class="mediumtags" align="right"><b><%=intl._("Fetch news through the eepProxy?")%></b></td>
<td><jsp:getProperty name="updatehelper" property="newsThroughProxy" /></td></tr>
<tr><td class="mediumtags" align="right"><b><%=intl._("Update through the eepProxy?")%></b></td> <tr><td class="mediumtags" align="right"><b><%=intl._("Update through the eepProxy?")%></b></td>
<td><jsp:getProperty name="updatehelper" property="updateThroughProxy" /></td></tr> <td><jsp:getProperty name="updatehelper" property="updateThroughProxy" /></td></tr>
<% if (updatehelper.isAdvanced()) { %> <% if (updatehelper.isAdvanced()) { %>