Changeset a48fba0


Ignore:
Timestamp:
Jun 12, 2013 3:07:39 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f939f68
Parents:
0292313
Message:
  • I2PTunnel: Add advanced quantity options
Location:
apps/i2ptunnel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java

    r0292313 ra48fba0  
    379379        return controller.getClientOptionProps();
    380380    }
     381
     382    private static final String PROP_ADVANCED = "routerconsole.advanced";
     383    private static final int DFLT_QUANTITY = 2;
     384    private static final int MAX_CLIENT_QUANTITY = 3;
     385    private static final int MAX_SERVER_QUANTITY = 6;
     386    private static final int MAX_ADVANCED_QUANTITY = 16;
     387
     388    /**
     389     *  @since 0.9.7
     390     */
     391    public String getQuantityOptions(int tunnel) {
     392        int tunnelQuantity = getTunnelQuantity(tunnel, DFLT_QUANTITY);
     393        boolean advanced = _context.getBooleanProperty(PROP_ADVANCED);
     394        int maxQuantity = advanced ? MAX_ADVANCED_QUANTITY :
     395                                     (isClient(tunnel) ? MAX_CLIENT_QUANTITY : MAX_SERVER_QUANTITY);
     396        if (tunnelQuantity > maxQuantity)
     397            maxQuantity = tunnelQuantity;
     398        StringBuilder buf = new StringBuilder(256);
     399        for (int i = 1; i <= maxQuantity; i++) {
     400             buf.append("<option value=\"").append(i).append('"');
     401             if (i == tunnelQuantity)
     402                 buf.append(" selected=\"selected\"");
     403             buf.append('>');
     404             buf.append(ngettext("{0} inbound, {0} outbound tunnel", "{0} inbound, {0} outbound tunnels", i));
     405             if (i <= 3) {
     406                 buf.append(" (");
     407                 if (i == 1)
     408                     buf.append(_("lower bandwidth and reliability"));
     409                 else if (i == 2)
     410                     buf.append(_("standard bandwidth and reliability"));
     411                 else if (i == 3)
     412                     buf.append(_("higher bandwidth and reliability"));
     413                 buf.append(')');
     414             }
     415             buf.append("</option>\n");
     416        }
     417        return buf.toString();
     418    }
    381419}
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java

    r0292313 ra48fba0  
    12941294        return Messages._(key, _context);
    12951295    }
     1296
     1297    /** translate (ngettext)
     1298     *  @since 0.9.7
     1299     */
     1300    protected String ngettext(String s, String p, int n) {
     1301        return Messages.ngettext(s, p, n, _context);
     1302    }
    12961303}
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/Messages.java

    r0292313 ra48fba0  
    4040        return Translate.getString(s, o, _context, BUNDLE_NAME);
    4141    }
     42
     43    /** translate (ngettext)
     44     *  @since 0.9.7
     45     */
     46    public static String ngettext(String s, String p, int n, I2PAppContext ctx) {
     47        return Translate.getString(n, s, p, ctx, BUNDLE_NAME);
     48    }
    4249}
  • apps/i2ptunnel/jsp/editClient.jsp

    r0292313 ra48fba0  
    248248                </label>
    249249                <select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
    250                     <% int tunnelQuantity = editBean.getTunnelQuantity(curTunnel, 2);
    251                   %><option value="1"<%=(tunnelQuantity == 1 ? " selected=\"selected\"" : "") %>><%=intl._("1 inbound, 1 outbound tunnel  (low bandwidth usage, less reliability)")%></option>
    252                     <option value="2"<%=(tunnelQuantity == 2 ? " selected=\"selected\"" : "") %>><%=intl._("2 inbound, 2 outbound tunnels (standard bandwidth usage, standard reliability)")%></option>
    253                     <option value="3"<%=(tunnelQuantity == 3 ? " selected=\"selected\"" : "") %>><%=intl._("3 inbound, 3 outbound tunnels (higher bandwidth usage, higher reliability)")%></option>
    254                 <% if (tunnelQuantity > 3) {
    255                 %>    <option value="<%=tunnelQuantity%>" selected="selected"><%=tunnelQuantity%>&nbsp;<%=intl._("tunnels")%></option>
    256                 <% }
    257               %></select>               
     250                    <%=editBean.getQuantityOptions(curTunnel)%>
     251                </select>               
    258252            </div>
    259253            <div id="backupField" class="rowItem">
  • apps/i2ptunnel/jsp/editServer.jsp

    r0292313 ra48fba0  
    265265                </label>
    266266                <select id="tunnelQuantity" name="tunnelQuantity" title="Number of Tunnels in Group" class="selectbox">
    267                     <% int tunnelQuantity = editBean.getTunnelQuantity(curTunnel, 2);
    268                   %><option value="1"<%=(tunnelQuantity == 1 ? " selected=\"selected\"" : "") %>><%=intl._("1 inbound, 1 outbound tunnel  (low bandwidth usage, less reliability)")%></option>
    269                     <option value="2"<%=(tunnelQuantity == 2 ? " selected=\"selected\"" : "") %>><%=intl._("2 inbound, 2 outbound tunnels (standard bandwidth usage, standard reliability)")%></option>
    270                     <option value="3"<%=(tunnelQuantity == 3 ? " selected=\"selected\"" : "") %>><%=intl._("3 inbound, 3 outbound tunnels (higher bandwidth usage, higher reliability)")%></option>
    271                     <option value="4"<%=(tunnelQuantity == 4 ? " selected=\"selected\"" : "") %>><%=intl._("4 in, 4 out (high traffic server)")%></option>
    272                     <option value="5"<%=(tunnelQuantity == 5 ? " selected=\"selected\"" : "") %>><%=intl._("5 in, 5 out (high traffic server)")%></option>
    273                     <option value="6"<%=(tunnelQuantity == 6 ? " selected=\"selected\"" : "") %>><%=intl._("6 in, 6 out (high traffic server)")%></option>
    274                 <% if (tunnelQuantity > 6) {
    275                 %>    <option value="<%=tunnelQuantity%>" selected="selected"><%=tunnelQuantity%>&nbsp;<%=intl._("tunnels")%></option>
    276                 <% }
    277               %></select>               
     267                    <%=editBean.getQuantityOptions(curTunnel)%>
     268                </select>               
    278269            </div>
    279270            <div id="backupField" class="rowItem">
Note: See TracChangeset for help on using the changeset viewer.