📄 transferspeedvalidator.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: TransferSpeedValidator.java
package org.gudy.azureus2.core3.config.impl;
import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.speedmanager.SpeedManager;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.global.GlobalManager;
public final class TransferSpeedValidator
{
public static final String AUTO_UPLOAD_ENABLED_CONFIGKEY = "Auto Upload Speed Enabled";
public static final String AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY = "Auto Upload Speed Seeding Enabled";
public static final String UPLOAD_CONFIGKEY = "Max Upload Speed KBs";
public static final String UPLOAD_SEEDING_CONFIGKEY = "Max Upload Speed Seeding KBs";
public static final String DOWNLOAD_CONFIGKEY = "Max Download Speed KBs";
public static final String UPLOAD_SEEDING_ENABLED_CONFIGKEY = "enable.seedingonly.upload.rate";
public static final String CONFIG_PARAMS[] = {
"Auto Upload Speed Enabled", "Auto Upload Speed Seeding Enabled", "Max Upload Speed KBs", "Max Upload Speed Seeding KBs", "Max Download Speed KBs", "enable.seedingonly.upload.rate"
};
private final String configKey;
private final Number configValue;
private static boolean seeding_upload_enabled;
public TransferSpeedValidator(String configKey, Number value)
{
this.configKey = configKey;
configValue = value;
}
private static Object validate(String configKey, Number value)
{
int newValue = value.intValue();
if (newValue < 0)
newValue = 0;
if (configKey == "Max Upload Speed KBs")
{
int downValue = COConfigurationManager.getIntParameter("Max Download Speed KBs");
if (newValue != 0 && newValue < 5 && (downValue == 0 || downValue > newValue * 2))
newValue = (downValue + 1) / 2;
} else
if (configKey == "Max Download Speed KBs")
{
int upValue = COConfigurationManager.getIntParameter("Max Upload Speed KBs");
if (upValue != 0 && upValue < 5)
if (newValue > upValue * 2)
newValue = upValue * 2;
else
if (newValue == 0)
newValue = upValue * 2;
} else
if (configKey != "Max Upload Speed Seeding KBs")
throw new IllegalArgumentException("Invalid Configuation Key; use key for max upload and max download");
return new Integer(newValue);
}
public Object getValue()
{
return validate(configKey, configValue);
}
public static String getActiveUploadParameter(GlobalManager gm)
{
if (seeding_upload_enabled && gm.isSeedingOnly())
return "Max Upload Speed Seeding KBs";
else
return "Max Upload Speed KBs";
}
public static String getDownloadParameter()
{
return "Max Download Speed KBs";
}
public static int getGlobalDownloadRateLimitBytesPerSecond()
{
return COConfigurationManager.getIntParameter(getDownloadParameter()) * 1024;
}
public static void setGlobalDownloadRateLimitBytesPerSecond(int bytes_per_second)
{
COConfigurationManager.setParameter(getDownloadParameter(), (bytes_per_second + 1023) / 1024);
}
public static boolean isAutoUploadAvailable(AzureusCore core)
{
return core.getSpeedManager().isAvailable();
}
public static String getActiveAutoUploadParameter(GlobalManager gm)
{
if (COConfigurationManager.getBooleanParameter("Auto Upload Speed Enabled"))
return "Auto Upload Speed Enabled";
if (gm.isSeedingOnly())
return "Auto Upload Speed Seeding Enabled";
else
return "Auto Upload Speed Enabled";
}
public static boolean isAutoSpeedActive(GlobalManager gm)
{
return COConfigurationManager.getBooleanParameter(getActiveAutoUploadParameter(gm));
}
static
{
COConfigurationManager.addAndFireParameterListener("enable.seedingonly.upload.rate", new ParameterListener() {
public void parameterChanged(String parameterName)
{
TransferSpeedValidator.seeding_upload_enabled = COConfigurationManager.getBooleanParameter(parameterName);
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -