forked from I2P_Developers/i2p.i2p
Router: Prep for a router strings bundle
This commit is contained in:
@ -16,11 +16,13 @@ import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.router.RouterAddress;
|
||||
import net.i2p.data.router.RouterInfo;
|
||||
import net.i2p.router.transport.Transport;
|
||||
import net.i2p.router.transport.crypto.DHSessionKeyBuilder;
|
||||
import net.i2p.util.Translate;
|
||||
|
||||
/**
|
||||
* Manages the communication subsystem between peers, including connections,
|
||||
@ -28,6 +30,10 @@ import net.i2p.router.transport.crypto.DHSessionKeyBuilder;
|
||||
*
|
||||
*/
|
||||
public abstract class CommSystemFacade implements Service {
|
||||
|
||||
/** @since 0.9.45 */
|
||||
protected static final String ROUTER_BUNDLE_NAME = "net.i2p.router.util.messages";
|
||||
|
||||
public abstract void processMessage(OutNetMessage msg);
|
||||
|
||||
public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException { }
|
||||
@ -83,6 +89,14 @@ public abstract class CommSystemFacade implements Service {
|
||||
*/
|
||||
public Status getStatus() { return Status.OK; }
|
||||
|
||||
/**
|
||||
* getStatus().toStatusString(), translated if available.
|
||||
* @since 0.9.45
|
||||
*/
|
||||
public String getLocalizedStatusString() {
|
||||
return getStatus().toStatusString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
@ -637,6 +651,14 @@ public abstract class CommSystemFacade implements Service {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* toStatusString(), translated if available.
|
||||
* @since 0.9.45
|
||||
*/
|
||||
public String toLocalizedStatusString(I2PAppContext ctx) {
|
||||
return Translate.getString(status, ctx, ROUTER_BUNDLE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " (" + code + "; " + status + ')';
|
||||
|
@ -48,6 +48,12 @@ public interface RouterThrottle {
|
||||
public String getTunnelStatus();
|
||||
public void setTunnelStatus(String msg);
|
||||
|
||||
/**
|
||||
* getTunnelStatus(), translated if available.
|
||||
* @since 0.9.45
|
||||
*/
|
||||
public String getLocalizedTunnelStatus();
|
||||
|
||||
/** @since 0.8.12 */
|
||||
public void setShutdownStatus();
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.i2p.stat.RateStat;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
import net.i2p.util.SystemVersion;
|
||||
import net.i2p.util.Translate;
|
||||
|
||||
/**
|
||||
* Simple throttle that basically stops accepting messages or nontrivial
|
||||
@ -529,6 +530,14 @@ public class RouterThrottleImpl implements RouterThrottle {
|
||||
return _tunnelStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* getTunnelStatus(), translated if available.
|
||||
* @since 0.9.45
|
||||
*/
|
||||
public String getLocalizedTunnelStatus() {
|
||||
return Translate.getString(_tunnelStatus, _context, CommSystemFacade.ROUTER_BUNDLE_NAME);
|
||||
}
|
||||
|
||||
private void setTunnelStatus() {
|
||||
// NPE, too early
|
||||
// if (_context.router().getRouterInfo().getBandwidthTier().equals("K"))
|
||||
|
@ -48,6 +48,9 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
* @since IPv6
|
||||
*/
|
||||
private static final String PROP_DISABLED = "i2np.disable";
|
||||
|
||||
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
|
||||
private static final String COUNTRY_BUNDLE_NAME = "net.i2p.router.countries.messages";
|
||||
|
||||
public CommSystemFacadeImpl(RouterContext context) {
|
||||
_context = context;
|
||||
@ -223,6 +226,15 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* getStatus().toStatusString(), translated if available.
|
||||
* @since 0.9.45
|
||||
*/
|
||||
@Override
|
||||
public String getLocalizedStatusString() {
|
||||
return Translate.getString(getStatus().toStatusString(), _context, ROUTER_BUNDLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
@ -553,9 +565,6 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
return n;
|
||||
}
|
||||
|
||||
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
|
||||
private static final String COUNTRY_BUNDLE_NAME = "net.i2p.router.countries.messages";
|
||||
|
||||
/** Provide a consistent "look" for displaying router IDs in the console */
|
||||
@Override
|
||||
public String renderPeerHTML(Hash peer) {
|
||||
|
Reference in New Issue
Block a user