Type fixes for i2pd

This commit is contained in:
zzz
2022-01-08 10:03:21 -05:00
parent 680d8a931b
commit 0a1a9285c6
4 changed files with 37 additions and 7 deletions

View File

@ -3,12 +3,14 @@
* Build fixes
* Support i2pcontrol HTTP Java console webapp at port 7657
* Layout fixes and adjustments
* Fixes for i2pd
* Graph adjustments
* Localize time format on graphs
* Move Settings from a popup frame to a new tab
* Remove "Change I2PControl" part of Settings
* Rename Configuration tab to "I2P Control"
* Remove "Settings read from I2P router" message
* Set graph values to 0 when router is gone
* Update to jchart2d 3.2.2 2011-09-25
* Remove debug output
* README updates

View File

@ -8,7 +8,7 @@ package net.i2p.itoopie;
public class ItoopieVersion {
/** Version of itoopie */
public static final String VERSION = "0.0.4-beta2";
public static final String VERSION = "0.0.4-beta3";
/** Version of the I2PControl API implemented */
public static final int I2PCONTROL_API_VERSION = 1;

View File

@ -227,13 +227,14 @@ public class ConfigurationTab extends TabLogoPanel {
EnumMap<NETWORK_SETTING, Object> em = GetNetworkSetting.execute(NETWORK_SETTING.TCP_PORT, NETWORK_SETTING.UDP_PORT,
NETWORK_SETTING.UPNP, NETWORK_SETTING.BW_IN, NETWORK_SETTING.BW_OUT, NETWORK_SETTING.BW_SHARE);
txtTCPPort.setText((String) em.get(NETWORK_SETTING.TCP_PORT));
txtUDPPort.setText((String) em.get(NETWORK_SETTING.UDP_PORT));
// i2pd may send these as numbers
txtTCPPort.setText(ConfigurationTab.toString(em.get(NETWORK_SETTING.TCP_PORT)));
txtUDPPort.setText(ConfigurationTab.toString(em.get(NETWORK_SETTING.UDP_PORT)));
boolean upnpValue = Boolean.parseBoolean((String) em.get(NETWORK_SETTING.UPNP));
chkbxUPNP.setSelected(upnpValue);
txtDownload.setText((String) em.get(NETWORK_SETTING.BW_IN));
txtUpload.setText((String) em.get(NETWORK_SETTING.BW_OUT));
txtShare.setText((String) em.get(NETWORK_SETTING.BW_SHARE));
txtDownload.setText(ConfigurationTab.toString(em.get(NETWORK_SETTING.BW_IN)));
txtUpload.setText(ConfigurationTab.toString(em.get(NETWORK_SETTING.BW_OUT)));
txtShare.setText(ConfigurationTab.toString(em.get(NETWORK_SETTING.BW_SHARE)));
//StatusHandler.setStatus(SETTINGS_READ);
} catch (InvalidPasswordException e) {
@ -245,6 +246,16 @@ public class ConfigurationTab extends TabLogoPanel {
});
}
/**
* Convert numbers to Strings for i2pd
* @since 0.0.4
*/
private static String toString(Object o) {
if (o == null)
return null;
return o.toString();
}
/**
* Launch the application.
*/

View File

@ -145,7 +145,8 @@ public class OverviewTab extends TabLogoPanel {
lblVersionSpecified.setText((String) em.get(ROUTER_INFO.VERSION));
lblUptimeSpecified.setText(DataHelper.formatDuration((Long) em.get(ROUTER_INFO.UPTIME)));
// i2pd sends as String
lblUptimeSpecified.setText(DataHelper.formatDuration(toLong(em.get(ROUTER_INFO.UPTIME))));
lblStatusSpecified.setText((String) em.get(ROUTER_INFO.STATUS));
Long netStatus = (Long) em.get(ROUTER_INFO.NETWORK_STATUS);
Integer intNetStatus = netStatus.intValue();
@ -165,6 +166,22 @@ public class OverviewTab extends TabLogoPanel {
}
}
/**
* Convert String to long for i2pd
* @since 0.0.4
*/
private static long toLong(Object o) {
if (o == null)
return 0;
if (o instanceof Number)
return ((Number) o).longValue();
if (o instanceof String) {
try {
return Long.parseLong((String) o);
} catch (NumberFormatException nfe) {}
}
return 0;
}
@Override
public void onTabFocus(ChangeEvent e) {