java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.WizardHelper
The new user wizard.
This bean has SESSION scope so the results may be retrieved. All necessary methods are synchronized.
Nested Class Summary
Nested ClassesField Summary
Modifier and TypeFieldDescriptionprivate intNumber of tests run so far.private StringStatus text of the last test.private WizardHelper.TestListenerListener recording the test results, session scope.private MLabRunnerThe bandwidth test runner, a singleton under the hood.private MLabRunner.ToolRunThe test running now, null if none.static final floatFraction of the measured bandwidth applied to the limiter settings.private static final floatSmallest download bandwidth the wizard accepts, in KBps.private static final floatSmallest upload bandwidth the wizard accepts, in KBps.static final StringSession property recording that the welcome wizard already ran.Fields inherited from class HelperBase
_context, _log, _out, CHECKED, PROP_ADVANCED, SELECTEDModifier and TypeFieldDescriptionprotected RouterContextThe router context.protected LogThe log instance.protected WriterThe writer for output.static final StringChecked attribute for HTML checkboxes.static final StringProperty key for advanced mode.static final StringSelected attribute for HTML select options.Constructor Summary
ConstructorsConstructorDescriptionA session-scoped bean with no test run yet: the listener, the runner and the cached status are all filled in as the bandwidth test runs.Method Summary
Modifier and TypeMethodDescription(package private) booleanCancel the test.voidcomplete()Record that the setup wizard has been finished, so it is not shown again.Return the NDT test completion status.Return detailed NDT test status information.longReturn the measured download bandwidth.To populate form with.Copied from ConfigNetHelper.private longgetLongResult(String key) Reads a numeric result of the last test.To populate form with.Copied from ConfigNetHelper.Return the NDT test server location.intAdapted from ConfigNetHelper.Copied from ConfigNetHelper.private StringgetStringResult(String key) Reads a text result of the last test.Return the current NDT bandwidth test status.longReturn the measured upload bandwidth.booleanWhether the NDT bandwidth test listener reports the test as finished.booleanWhether the NDT bandwidth test is in progress.booleanWhether the NDT bandwidth test completed and moved any bandwidth in both directions.private StringkbytesToBits(float kbytes) Copied from ConfigNetHelper.voidsetContextId(String contextId) Overriden to only do this once.(package private) booleanstartNDT()Start the test.Methods inherited from class HelperBase
_t, _t, _t, _x, getChecked, isAdvanced, ngettext, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected StringgetChecked(String prop) Get the checked attribute for a boolean property.booleanCheck if advanced mode is enabled.Translate a string with plural forms (ngettext).voidstoreWriter(Writer out) Store the writer for output.
Field Details
PROP_COMPLETE
Session property recording that the welcome wizard already ran.- See Also:
BW_SCALE
public static final float BW_SCALEFraction of the measured bandwidth applied to the limiter settings.- See Also:
MIN_DOWN_BW
private static final float MIN_DOWN_BWSmallest download bandwidth the wizard accepts, in KBps.- See Also:
MIN_UP_BW
private static final float MIN_UP_BWSmallest upload bandwidth the wizard accepts, in KBps.- See Also:
_mlab
The bandwidth test runner, a singleton under the hood._listener
Listener recording the test results, session scope._runner
The test running now, null if none._lastTestStatus
Status text of the last test._lastTestCount
private int _lastTestCountNumber of tests run so far.
Constructor Details
WizardHelper
public WizardHelper()A session-scoped bean with no test run yet: the listener, the runner and the cached status are all filled in as the bandwidth test runs.
Method Details
setContextId
Overriden to only do this once.- Overrides:
setContextIdin classHelperBase- Parameters:
contextId- beginning few characters of the routerHash, or null to pick the first one we come across.
complete
public void complete()Record that the setup wizard has been finished, so it is not shown again.isNDTComplete
public boolean isNDTComplete()Whether the NDT bandwidth test listener reports the test as finished.- Returns:
- whether n d t complete
isNDTRunning
public boolean isNDTRunning()Whether the NDT bandwidth test is in progress.- Returns:
- whether n d t running
isNDTSuccessful
public boolean isNDTSuccessful()Whether the NDT bandwidth test completed and moved any bandwidth in both directions.- Returns:
- whether n d t successful
getTestStatus
Return the current NDT bandwidth test status.- Returns:
- HTML-escaped status string or ""
getCompletionStatus
Return the NDT test completion status.- Returns:
- HTML-escaped status string or ""
getDetailStatus
Return detailed NDT test status information.- Returns:
- HTML-escaped status string or ""
getUpBandwidth
public long getUpBandwidth()Return the measured upload bandwidth.- Returns:
- bytes per second or 0
getDownBandwidth
public long getDownBandwidth()Return the measured download bandwidth.- Returns:
- bytes per second or 0
getServerLocation
Return the NDT test server location.- Returns:
- HTML-escaped location or ""
getLongResult
Reads a numeric result of the last test.- Parameters:
key- the result name- Returns:
- the value, zero if absent
getStringResult
getInboundBurstRate
To populate form with. Uses the test result if available, else the current setting Adapted fromConfigNetHelper.- Returns:
- the inbound bandwidth limit in decimal KB/sec, rounded to an integer
getOutboundBurstRate
To populate form with. Uses the test result if available, else the current setting Adapted from ConfigNetHelper.- Returns:
- the outbound bandwidth limit in decimal KB/sec, rounded to an integer
getInboundBurstRateBits
Copied from ConfigNetHelper.- Returns:
- the inbound burst rate in bits per second and the per-month maximum
getOutboundBurstRateBits
Copied from ConfigNetHelper.- Returns:
- the outbound burst rate in bits per second and the per-month maximum
kbytesToBits
Copied from ConfigNetHelper.- Parameters:
kbytes- the bandwidth in KB/sec, where 1 KB is 1024 bytes- Returns:
- the rate in bits per second, plus the per-month byte maximum
startNDT
boolean startNDT()Start the test. Called from the Handler.- Returns:
- whether the test was started; false if one is already running
cancelNDT
boolean cancelNDT()Cancel the test. Called from the Handler.- Returns:
- whether a running test was cancelled