Changeset d1bd893 for apps/ministreaming


Ignore:
Timestamp:
May 18, 2014 9:13:22 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4167cd95
Parents:
2467856
Message:
  • I2PTunnel:
    • Display custom error pages for I2PSocketExceptions (ticket #788)
    • Tag I2PSocketException text for translation (no bundles yet)
    • Move methods from superclasses to I2PTunnelHTTPClientBase
    • Fix connect client error pages, but they aren't displayed anyway
    • Don't start I2PTunnelRunner threads in constructor (ticket #973)
    • Synch close() in I2PTunnelServer
    • Cleanups and javadocs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketException.java

    r2467856 rd1bd893  
    33import java.net.SocketException;
    44
     5import net.i2p.I2PAppContext;
    56import net.i2p.client.SendMessageStatusListener;
    67import net.i2p.data.i2cp.MessageStatusMessage;
     8import net.i2p.util.Translate;
    79
    810/**
    9  *  An I2P-specific IOException thrown from input and output streams.
     11 *  An I2P-specific IOException thrown from input and output streams,
    1012 *  with a stored status code to be used for programmatic responses.
    1113 *
     
    1618    private final int _status;
    1719    private static final int CUSTOM = -1;
     20    private static final String BUNDLE_NAME = "net.i2p.client.streaming.messages";
    1821
    1922    /**
     
    5356            case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
    5457            case MessageStatusMessage.STATUS_SEND_GUARANTEED_FAILURE:
    55                 return "Message timeout";
     58                return _x("Message timeout");
    5659
    5760            case MessageStatusMessage.STATUS_SEND_FAILURE_LOCAL:
    58                 return "Failed delivery to local destination";
     61                return _x("Failed delivery to local destination");
    5962
    6063            case MessageStatusMessage.STATUS_SEND_FAILURE_ROUTER:
    61                 return "Local router failure";
     64                return _x("Local router failure");
    6265
    6366            case MessageStatusMessage.STATUS_SEND_FAILURE_NETWORK:
    64                 return "Local network failure";
     67                return _x("Local network failure");
    6568
    6669            case MessageStatusMessage.STATUS_SEND_FAILURE_BAD_SESSION:
    67                 return "Session closed";
     70                return _x("Session closed");
    6871
    6972            case MessageStatusMessage.STATUS_SEND_FAILURE_BAD_MESSAGE:
    70                 return "Invalid message";
     73                return _x("Invalid message");
    7174
    7275            case MessageStatusMessage.STATUS_SEND_FAILURE_BAD_OPTIONS:
    73                 return "Invalid message options";
     76                return _x("Invalid message options");
    7477
    7578            case MessageStatusMessage.STATUS_SEND_FAILURE_OVERFLOW:
    76                 return "Buffer overflow";
     79                return _x("Buffer overflow");
    7780
    7881            case MessageStatusMessage.STATUS_SEND_FAILURE_EXPIRED:
    79                 return "Message expired";
     82                return _x("Message expired");
    8083
    8184            case MessageStatusMessage.STATUS_SEND_FAILURE_LOCAL_LEASESET:
    82                 return "Local lease set invalid";
     85                return _x("Local lease set invalid");
    8386
    8487            case MessageStatusMessage.STATUS_SEND_FAILURE_NO_TUNNELS:
    85                 return "No local tunnels";
     88                return _x("No local tunnels");
    8689
    8790            case MessageStatusMessage.STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTION:
    88                 return "Unsupported encryption options";
     91                return _x("Unsupported encryption options");
    8992
    9093            case MessageStatusMessage.STATUS_SEND_FAILURE_DESTINATION:
    91                 return "Invalid destination";
     94                return _x("Invalid destination");
    9295
    9396            case MessageStatusMessage.STATUS_SEND_FAILURE_BAD_LEASESET:
    94                 return "Local router failure";
     97                return _x("Local router failure");
    9598
    9699            case MessageStatusMessage.STATUS_SEND_FAILURE_EXPIRED_LEASESET:
    97                 return "Destination lease set expired";
     100                return _x("Destination lease set expired");
    98101
    99102            case MessageStatusMessage.STATUS_SEND_FAILURE_NO_LEASESET:
    100                 return "Destination lease set not found";
     103                return _x("Destination lease set not found");
    101104
    102105            case SendMessageStatusListener.STATUS_CANCELLED:
    103                 return "Local destination shutdown";
     106                return _x("Local destination shutdown");
    104107
    105108            case CUSTOM:
     
    110113        }
    111114    }
     115
     116    /**
     117     *  Translated
     118     */
     119    @Override
     120    public String getLocalizedMessage() {
     121        String s = getMessage();
     122        if (s == null)
     123            return null;
     124        return Translate.getString(s, I2PAppContext.getGlobalContext(), BUNDLE_NAME);
     125    }
     126
     127    /**
     128     *  Tag for translation
     129     */
     130    private static String _x(String s) {
     131        return s;
     132    }
    112133}
Note: See TracChangeset for help on using the changeset viewer.